A Set of Mathematical Helper routines to simply Cross-Platfrom Canvas drawing etc
TFloatPoint
- an extended precision record specifying the X and Y coordinates of a point in a graphic environment
Angles2Coords
- convert an Eccentric Angle and an Angle-Length, into the coords for Start and End Radial-Points

Method: Angles2Coords

    Params:   x,y,width,height,angle1,angle2, sx, sy, ex, ey
      Returns:  Nothing

      Use Angles2Coords to convert an Eccentric(aka Radial) Angle and an
      Angle-Length, such as are used in X-Windows and GTK, into the coords,
      for Start and End Radial-Points, such as are used in the Windows API Arc
      Pie and Chord routines. The angles are 1/16th of a degree. For example, a
      full circle equals 5760 (16*360). Positive values of Angle and AngleLength
      mean counter-clockwise while negative values mean clockwise direction.
      Zero degrees is at the 3 o'clock position.

Arc2Bezier
- convert an Arc and ArcLength into a Bezier Aproximation of the Arc.

Method: Arc2Bezier

    Params:   X, Y, Width, Height, Angle1, Angle2, Rotation, Points, Count
      Returns:  Nothing

      Use Arc2Bezier to convert an Arc and ArcLength into a Bezier Aproximation
      of the Arc. The Rotation parameter accepts a Rotation-Angle for a rotated
      Ellipse'- for a non-rotated ellipse this value would be 0, or 360. If the
      AngleLength is greater than 90 degrees, or is equal to 0, it automatically
      exits, as Bezier cannot accurately aproximate any angle greater then 90
      degrees, and in fact for best result no angle greater than 45 should be
      converted, instead an array of Bezier's should be created, each Bezier
      descibing a portion of the total arc no greater than 45 degrees. The angles
      are 1/16th of a degree. For example, a full circle equals 5760 (16*360).
      Positive values of Angle and AngleLength mean counter-clockwise while
      negative values mean clockwise direction. Zero degrees is at the 3 o'clock
      position.

Bezier
- function to get a Bezierfigure from the given points
Bezier2Polyline
- convert a 4-Point Bezier into a Pointer Array of TPoint and a Count variable

Method: Bezier2Polyline

    Params:   Bezier, Points, Count
      Returns:  Nothing

      Use BezierToPolyline to convert a 4-Point Bezier into a Pointer Array of
      TPoint and a Count variable which can then be used within either a Polyline,
      or Polygon routine. It is primarily for use within PolyBezier2Polyline. If
      Points is not initialized or Count is less then 0, it is set to nil and
      the array starts at 0, otherwise it tries to append points
      to the array starting at Count. Points should ALWAYS be Freed when done
      by calling to ReallocMem(Points, 0) or FreeMem.

BezierArcPoints
- convert an Arc and ArcLength into a Pointer Array of TPoints for use with Polyline or Polygon

Method: BezierArcPoints

    Params:   X, Y, Width, Height, Angle1, Angle2, Rotation, Points, Count
      Returns:  Nothing

      Use BezierArcPoints to convert an Arc and ArcLength into a Pointer Array
      of TPoints for use with Polyline or Polygon. The Rotation parameter accepts
      a Rotation-Angle for a rotated Ellipse'- for a non-rotated ellipse this
      value would be 0, or 360. The result is an Aproximation based on 1 or more
      Beziers. If the AngleLength is greater than 90 degrees, it calls
      PolyBezierArcPoints, otherwise it Converts the angles into a Bezier by
      calling to Arc2Bezier, and then converts the Bezier into an array of Points
      by calling to Bezier2Polyline. The angles are 1/16th of a degree. For example,
      a full circle equals 5760 (16*360). Positive values of Angle and AngleLength
      mean counter-clockwise while negative values mean clockwise direction. Zero
      degrees is at the 3'o clock position. If Points is not initialized or Count
      is less then 0, it is set to nil and the array starts at 0,
      otherwise it tries to append points to the array starting at Count. Points
      should ALWAYS be Freed when done by calling ReallocMem(Points, 0) or FreeMem.

BezierMidPoint
- get the Mid-Point of any 4-Point Bezier. It is primarily for use in SplitBezier.
CenterPoint
- get the Center-Point of any rectangle. It is primarily for use with, and in, other routines such as Quadrant, and RadialPoint
Coords2Angles
- convert the coords for Start and End Radial-Points into an Eccentric counter clockwise Angle and an Angle-Length

Method: Coords2Angles

    Params:   x,y,width,height,sx,sy,ex,ey, angle1,angle2
      Returns:  Nothing

      Use Coords2Angles to convert the coords for Start and End Radial-Points, such
      as are used in the Windows API Arc Pie and Chord routines, into an Eccentric
      (aka Radial) counter clockwise Angle and an Angle-Length, such as are used in
      X-Windows and GTK. The angles angle1 and angle2 are returned in 1/16th of a
      degree. For example, a full circle equals 5760 (16*360). Zero degrees is at
      the 3 o'clock position.

Get the Distance between any two Points. It is primarily for use in other routines such as EccentricAngle
EccentricAngle
- get the Eccentric Angle of a given point on any non-rotated ellipse

Method: EccentricAngle

    Params:   Pt, Rect
      Returns:  Extended

      Use EccentricAngle to get the Eccentric( aka Radial ) Angle of a given
      point on any non-rotated ellipse. It is primarily for use in Coords2Angles.
      The result is in 1/16th of a degree. For example, a full circle equals
      5760 (16*360).  Zero degrees is at the 3 o'clock position.

EllipseRadialLength
- Radial-Length of non-rotated ellipse at any given Eccentric Angle

Method: EllipseRadialLength

    Params:   Rect, EccentricAngle
      Returns:  Longint

      Use EllipseRadialLength to get the Radial-Length of non-rotated ellipse at
      any given Eccentric( aka Radial ) Angle. It is primarily for use in other
      routines such as RadialPoint. The Eccentric angle is in 1/16th of a degree.
      For example, a full circle equals 5760 (16*360).  Zero degrees is at the
      3 o'clock position.

FloatPoint
- it is essentialy like Classes.Point in use, except that it accepts Extended Parameters. It is Primarily for use with and in Bezier routines.
LineEndPoint
- get the End-Point of a line of any given Length at any given angle with any given Start-Point

Method: LineEndPoint

    Params:   StartPoint, Angle, Length
      Returns:  TPoint

      Use LineEndPoint to get the End-Point of a line of any given Length at
      any given angle with any given Start-Point. It is primarily for use in
      other routines such as RadialPoint. The angle is in 1/16th of a degree.
      For example, a full circle equals 5760 (16*360).  Zero degrees is at the
      3 o'clock position.

PolyBezier2Polyline
- convert an array of 4-Point Bezier into a Pointer Array of TPoint and a Count variable

Method: PolyBezier2Polyline

    Params:   Beziers, Points, Count
      Returns:  Nothing

      Use BezierToPolyline to convert an array of 4-Point Bezier into a Pointer
      Array of TPoint and a Count variable which can then be used within either a
      Polyline, or Polygon routine. Points is automatically initialized, so any
      existing information is lost, and the array starts at 0. Points should ALWAYS
      be Freed when done by calling to ReallocMem(Points, 0).

PolyBezierArcPoints
- convert an Arc and ArcLength into a Pointer Array of TPoints for use with Polyline or Polygon

Method: PolyBezierArcPoints

    Params:   X, Y, Width, Height, Angle1, Angle2, Rotation, Points, Count
      Returns:  Nothing

      Use PolyBezierArcPoints to convert an Arc and ArcLength into a Pointer Array
      of TPoints for use with Polyline or Polygon. The Rotation parameter accepts
      a Rotation-Angle for a rotated Ellipse'- for a non-rotated ellipse this
      value would be 0, or 360. The result is an Aproximation based on 1 or more
      Beziers. If the AngleLength is greater than 45 degrees, it recursively breaks
      the Arc into Arcs of 45 degrees or less, and converts them into Beziers with
      BezierArcPoints. The angles are 1/16th of a degree. For example, a full circle
      equals 5760 (16*360). Positive values of Angle and AngleLength mean
      counter-clockwise while negative values mean clockwise direction. Zero
      degrees is at the 3'o clock position. Points is automatically initialized,
      so any existing information is lost, and the array starts at 0. Points
      should ALWAYS be Freed when done by calling to ReallocMem(Points, 0).

Determine the Quadrant of any point, given the Center

Method: Quadrant

    Params:   PT, Center
      Returns:  Integer

      Use Quadrant to determine the Quadrant of any point, given the Center.
      It is primarily for use in other routines such as EccentricAngle. A result
      of 1-4 represents the primary 4 quardants. A result of 5-8 means the point
      lies on one of the Axis', 5 = -Y Axis, 6 = +X Axis, 7 = +Y Axis, and
      8 = -X Axis. A result of -1 means that it does not fall in any quadrant,
      that is, it is the Center.

Get the RadialPoint at any given Eccentric angle on any non-rotated ellipse

Method: RadialPoint

    Params:   EccentricAngle, Rect
      Returns:  TPoint

      Use RadialPoint to get the Radial-Point at any given Eccentric( aka Radial )
      angle on any non-rotated ellipse. It is primarily for use in Angles2Coords.
      The EccentricAngle is in 1/16th of a degree. For example, a full circle
      equals 5760 (16*360).  Zero degrees is at the 3 o'clock position.

SplitBezier
- split any 4-Point Bezier into two 4-Point Beziers: a 'Left' and a 'Right'

Method: SplitBezier

    Params:   Bezier, Left, Right
      Returns:  Nothing

      Use SplitBezier to split any 4-Point Bezier into two 4-Point Beziers:
      a 'Left' and a 'Right'. It is primarily for use in Bezier2Polyline.

GraphMath Operators

This Unit contains a number of routines for calculating and converting series of graphic points from one coordinate system to another.

A fundamental type is introduced, called TFloatPoint. It is an extended precision record containg an X and a Y coordinate for a graphic point. Its structure is as follows:

    Type
      TFloatPoint = Record
        X, Y : Extended;
      end;

The Unit contains definitions for mathematical operators which extend the normal definitions of addition, subtraction, multiplication, division and comparison to cover manipulations with TFloatPoints, allowing, for example, addition or multiplication of two TFloatPoints, a TFloatPoint and a TPoint, or a TFloatPoint and an Extended Precision number.