geomobjs(3U)

🌸 NAME 🌸

PointObj, LineObj, BoxObj, MultiLineObj, FillPolygonObj, Extent β€” helper classes that manage geometric information for structured graphics

okay so bestie, welcome to geomobjs(3U) πŸ’– this is straight out of the InterViews Reference Manual, section 3U, and it's literally the little squad of classes that hold all the geometry for you. let's get into it ✨


πŸŽ€ SYNOPSIS πŸŽ€

#include <Unidraw/Graphic/geomobjs.h>

✨ DESCRIPTION ✨

Unidraw defines several helper classes that store and manage geometric information. Structured graphics objects may use these helper classes to support their semantics. No cap.

  • PointObj stores a point 🫢
  • LineObj stores two points
  • MultiLineObj stores any number of points
  • BoxObj and FillPolygonObj define rectangular and polygonal areas, respectively
  • Extent stores extent information β€” that is, the lower left corner and center of a bounding box, plus a fixed amount of extra space around the bounding box

and literally all of these classes provide operations for computing geometric information. it's giving math girlie, and she ate πŸ’…


πŸ’œ POINTOBJ PUBLIC OPERATIONS πŸ’œ

  • PointObj(Coord = 0, Coord = 0), PointObj(PointObj*) β€” construct a PointObj, supplying either two Coords or another PointObj to specify the instance's coordinates. those coords get stored in its _x and _y public members πŸ‘‘
  • float Distance(PointObj&) β€” return the distance between this and the given PointObj. that's it. that's the whole job 🌸

πŸ’™ LINEOBJ PUBLIC OPERATIONS πŸ’™

  • LineObj(Coord = 0, Coord = 0, Coord = 0, Coord = 0), LineObj(LineObj*) β€” construct a LineObj, supplying either two coordinate pairs or another LineObj to specify the instance's endpoints. those endpoints live in its _p1 and _p2 public members πŸŽ€
  • boolean Contains(PointObj&), boolean Intersects(LineObj&) β€” return whether this contains the given point, and whether it intersects the given line, respectively. two for one, we love a bundle ✨
  • int Same(PointObj& p1, PointObj& p2) β€” a helper function used in Intersects. Same returns a positive value if p1 and p2 fall on the same side of the line, 0 if both points fall on the line, or a negative value if the points are on opposite sides of the line. sign-coded fr fr πŸ’…

🧊 BOXOBJ PUBLIC OPERATIONS 🧊

  • BoxObj(Coord = 0, Coord = 0, Coord = 0, Coord = 0), BoxObj(BoxObj*) β€” construct a BoxObj, supplying either two coordinate pairs or another BoxObj to specify the instance's bottom-left and top-right corners. they're stored in its _left, _bottom, _right, and _top public members πŸ“¦
  • boolean Contains(PointObj&), boolean Intersects(BoxObj&), boolean Intersects(LineObj&) β€” return whether this contains the given point, and whether it intersects the given box or line, respectively πŸ¦‹
  • BoxObj operator - (BoxObj&), BoxObj operator + (BoxObj&) β€” compute the intersection (-) or union (+) of this and the given box, returning the result. these operations do not affect this or their argument β€” they're not out here mutating anybody, they're just doing the math and handing you the answer 🌈
  • boolean Within(BoxObj&) β€” return true if this falls completely within the given box. Within will also return true if the boxes are identical. twins!! πŸ‘―

🌟 MULTILINEOBJ PUBLIC OPERATIONS 🌟

  • MultiLineObj(Coord* = nil, Coord* = nil, int = 0) β€” create a MultiLineObj, optionally supplying coordinate arrays (and their size) that define the vertices of the multiline.
⚠️ real talk: the MultiLineObj does not copy these arrays β€” it stores them directly. so like, don't go freeing them behind its back, iykyk 😭

the MultiLineObj stores this information in its _x, _y, and _count public members.

  • void GetBox(BoxObj&) β€” calculate the bounding box circumscribing the MultiLineObj's vertices and store it in the argument πŸ“
  • boolean Contains(PointObj&), boolean Intersects(BoxObj&), boolean Intersects(LineObj&) β€” return whether this contains the given point, and whether it intersects the given box or line, respectively πŸ’–
  • boolean Within(BoxObj&) β€” return true if this falls completely within the MultiLineObj's bounding box. Within will also return true if the boxes are identical 🌸
  • void SplineToMultiLine(Coord* cpx, Coord* cpy, int count), void ClosedSplineToMultiLine(Coord* cpx, Coord* cpy, int count) β€” linearize the open or closed B-Spline defined by the given set of control points and store the result in this. these operations store the linearized result in internal buffers and assign the addresses of these buffers to _x and _y; they do not delete _x and _y if they are non-nil prior to assignment πŸŒ€

πŸ”’ MULTILINEOBJ PROTECTED OPERATIONS πŸ”’

  • void GrowBuf() β€” increase the size of the internal buffers used to store linearized splines. glow-up for your buffers ✨
  • boolean CanApproxWithLine(double x0, double, y0, double x1, double y1, double x2, double y2) β€” return whether two connected line segments defined by the given three points can be approximated visually with a single line between the endpoints πŸ‘€
  • void AddLine(double x0, double y0, double x1, double y1) β€” add a line to the internal buffer of vertices πŸ–ŠοΈ
  • void AddBezierArc(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3) β€” add lines approximating the appearance of a Bezier arc defined by the given points to the internal buffer of vertices 🎒
  • void CalcSection(Coord cminus1x, Coord cminus1y, Coord cx, Coord cy, Coord cplus1x, Coord cplus1y, Coord cplus2x, Coord cplus2y) β€” add a Bezier arc to the internal buffer of vertices based on a series of four B-spline control points: the one before and the two after (cx, cy) πŸ’«

πŸ“ FILLPOLYGONOBJ PUBLIC OPERATIONS πŸ“

  • FillPolygonObj(Coord* = nil, Coord* = nil, int = 0) β€” create a new FillPolygonObj, optionally specifying its vertices. if vertices are supplied, then the constructor uses Normalize (described below) to store a normalized set of vertices in the FillPolygonObj's _normx, _normy, and _normCount public members. FillPolygonObj is a subclass of MultiLineObj; thus it stores the constructor arguments in its _x, _y, and _count public members 🧚
  • virtual ~FillPolygonObj() β€” the destructor deletes the _normx and _normy arrays. clean up after yourself bestie 🧹
  • boolean Contains(PointObj&), boolean Intersects(BoxObj&), boolean Intersects(LineObj&) β€” return whether this contains the given point, and whether it intersects the given box or line, respectively 🌈

🎨 FILLPOLYGONOBJ PROTECTED OPERATIONS 🎨

  • void Normalize() β€” copy the vertices defined by _x, _y, and _count into _normx, _normy, and _normCount such that (_normx[0], _normy[0]) is the lower-leftmost vertex and there are no redundant vertices. tidy, organized, main character energy πŸ‘‘

πŸ’« EXTENT PUBLIC OPERATIONS πŸ’«

  • Extent(float left = 0, float bottom = 0, float cx = 0, float cy = 0, float tol = 0), Extent(Extent&) β€” construct a new Extent, optionally supplying its parameters explicitly or providing an existing Extent to copy. the parameters are stored in the Extent's _left, _bottom, _cx, _cy, and _tol public members 🫢
  • boolean Undefined() β€” return whether the extent is undefined, that is, if (_left, _bottom) and (_cx, _cy) are the same point. if the corner and the center are the same spot... yeah girl, that's undefined πŸ’€
  • boolean Within(Extent&) β€” return true if the given extent circumscribes this. Within will also return true if the extents are identical πŸ‘―
  • void Merge(Extent&) β€” enlarge this extent to subsume area of the given extent. absorbing, periodt 🫧

πŸ‘€ SEE ALSO πŸ‘€

  • Graphic(3U)

and that's the whole page, bestie!! you're officially fluent in geometry helper classes πŸ’…βœ¨

this lil love letter came to you from Unidraw, dated 2 February 1991 πŸŽ€ go forth and compute geometric information, queen πŸ‘‘πŸ’–