Logo Euclid

Rect2D Type

A struct containing a 2D Origin point and two 2D Edge vectors, representing an immutable 2D rectangle with any rotation in 2D space. This implementation guarantees the 2D rectangle to be always valid. That means the X and Y axes are always perpendicular to each other. However the length of one of these axes might still be zero.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Record fields

Record Field Description

OriginX

Full Usage: OriginX

Field type: float

The X coordinate of the Origin Corner of the 2D Rectangle.

Field type: float

OriginY

Full Usage: OriginY

Field type: float

The Y coordinate of the Origin Corner of the 2D Rectangle.

Field type: float

XAxisX

Full Usage: XAxisX

Field type: float

The X component of the Edge vector representing the X-axis of the 2D Rectangle.

Field type: float

XAxisY

Full Usage: XAxisY

Field type: float

The Y component of the Edge vector representing the X-axis of the 2D Rectangle.

Field type: float

YAxisX

Full Usage: YAxisX

Field type: float

The X component of the Edge vector representing the Y-axis of the 2D Rectangle.

Field type: float

YAxisY

Full Usage: YAxisY

Field type: float

The Y component of the Edge vector representing the Y-axis of the 2D Rectangle.

Field type: float

Instance members

Instance member Description

this.Area

Full Usage: this.Area

Returns: float
Modifiers: inline

Calculates the area of the 2D Rectangle.

Returns: float

this.AsFSharpCode

Full Usage: this.AsFSharpCode

Returns: string

Format Rect2D into an F# code string that can be used to recreate the rectangle.

Returns: string

this.AsString

Full Usage: this.AsString

Returns: string

Format the 2D rectangle into string with nice floating point number formatting of X and Y size only. But without type name as in v.ToString()

Returns: string

this.Center

Full Usage: this.Center

Returns: Pt
Modifiers: inline

Returns the center of the 2D Rectangle.

Returns: Pt

this.ClosestParameters

Full Usage: this.ClosestParameters

Parameters:
    p : Pt - The point to find the closest parameters for.

Returns: float * float A tuple of the X and Y parameters, not clamped to the range 0.0 to 1.0.

Returns the X and Y parameters of the closest point on the 2D rectangle to a given point. If the parameters are outside the range of 0.0 to 1.0, the given point is outside the rectangle. Fails if the X- or Y-axis of the rectangle is shorter than 1e-6.

p : Pt

The point to find the closest parameters for.

Returns: float * float

A tuple of the X and Y parameters, not clamped to the range 0.0 to 1.0.

this.ClosestPoint

Full Usage: this.ClosestPoint

Parameters:
    p : Pt - The point to find the closest point for.

Returns: Pt The closest point on or inside the 2D rectangle.

Returns the closest point on the 2D rectangle to a given point. For a point inside the rectangle, this is the point itself, up to floating-point rounding. A point outside the rectangle is clamped onto its edge. Fails if the X- or Y-axis of the rectangle is shorter than 1e-6.

p : Pt

The point to find the closest point for.

Returns: Pt

The closest point on or inside the 2D rectangle.

this.ContainsPt

Full Usage: this.ContainsPt

Parameters:
Returns: bool

Check for point containment in the 2D Rectangle. By doing 4 dot products with the sides of the rectangle. A point exactly on the edge of the rectangle is considered inside.

p : Pt
Returns: bool

this.ContainsXY

Full Usage: this.ContainsXY

Parameters:
    x : float
    y : float

Returns: bool

Check for point containment in the 2D Rectangle. By doing 4 dot products with the sides of the rectangle. A point exactly on the edge of the rectangle is considered inside.

x : float
y : float
Returns: bool

this.CountZeroSides

Full Usage: this.CountZeroSides

Returns: int
Modifiers: inline

Counts the amount of sides that are smaller than the zeroLength tolerance. This is 0, 1 or 2.

Returns: int

this.Diagonal

Full Usage: this.Diagonal

Returns: Vc
Modifiers: inline

Returns the diagonal vector of the 2D Rectangle. From Origin to FarCorner.

Returns: Vc

this.DiagonalLine

Full Usage: this.DiagonalLine

Returns: Line2D
Modifiers: inline

Returns the diagonal 2D line from point 0 to 2 of the 2D rectangle.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Line2D

this.Edge01

Full Usage: this.Edge01

Returns: Line2D
Modifiers: inline

Returns a 2D line from point 0 to 1 of the 2D rectangle.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Line2D

this.Edge03

Full Usage: this.Edge03

Returns: Line2D
Modifiers: inline

Returns a 2D line from point 0 to 3 of the 2D rectangle. This is the reverse of Edge30.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Line2D

this.Edge10

Full Usage: this.Edge10

Returns: Line2D
Modifiers: inline

Returns a 2D line from point 1 to 0 of the 2D rectangle. This is the reverse of Edge01.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Line2D

this.Edge12

Full Usage: this.Edge12

Returns: Line2D
Modifiers: inline

Returns a 2D line from point 1 to 2 of the 2D rectangle.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Line2D

this.Edge21

Full Usage: this.Edge21

Returns: Line2D
Modifiers: inline

Returns a 2D line from point 2 to 1 of the 2D rectangle. This is the reverse of Edge12.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Line2D

this.Edge23

Full Usage: this.Edge23

Returns: Line2D
Modifiers: inline

Returns a 2D line from point 2 to 3 of the 2D rectangle.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Line2D

this.Edge30

Full Usage: this.Edge30

Returns: Line2D
Modifiers: inline

Returns a 2D line from point 3 to 0 of the 2D rectangle.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Line2D

this.Edge32

Full Usage: this.Edge32

Returns: Line2D
Modifiers: inline

Returns a 2D line from point 3 to 2 of the 2D rectangle. This is the reverse of Edge23.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Line2D

this.EdgeX

Full Usage: this.EdgeX

Returns: Line2D
Modifiers: inline

Returns the local X side as the 2D line from point 0 to 1 of the 2D rectangle.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Line2D

this.EdgeY

Full Usage: this.EdgeY

Returns: Line2D
Modifiers: inline

Returns the local Y side as 2D line from point 0 to 3 of the 2D rectangle. This is the reverse of Edge30.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Line2D

this.Edges

Full Usage: this.Edges

Returns: Line2D[]

Returns the 4 Edges of the 2D rectangle in counter-clockwise order, starting at Origin. Returns an array of 4 Lines: from point 0 to 1, 1 to 2 to 3 and 3 to 0.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Line2D[]

this.EvaluateAt

Full Usage: this.EvaluateAt

Parameters:
    xParameter : float
    yParameter : float

Returns: Pt
Modifiers: inline
 Evaluate an X and Y parameter of the 2D rectangle.
  0.0, 0.0 returns the Origin.
  1.0, 1.0 returns the FarCorner.
xParameter : float
yParameter : float
Returns: Pt

this.EvaluateDistance

Full Usage: this.EvaluateDistance

Parameters:
    xDistance : float
    yDistance : float

Returns: Pt
Modifiers: inline

Evaluate a point at X and Y distance on the respective axes of the 2D Rectangle.

xDistance : float
yDistance : float
Returns: Pt

this.FarCorner

Full Usage: this.FarCorner

Returns: Pt
Modifiers: inline

Returns the corner diagonally opposite of corner from Origin (point 2). r.Origin + r.XAxis + r.YAxis

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Pt

this.GetEdge

Full Usage: this.GetEdge

Parameters:
    i : int

Returns: Line2D

Returns one of the 4 Edges as 2D Line: Edge 0: from point 0 to 1 Edge 1: from point 1 to 2 Edge 2: from point 2 to 3 Edge 3: from point 3 to 0

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

i : int
Returns: Line2D

this.HasArea

Full Usage: this.HasArea

Returns: bool
Modifiers: inline

Tests if neither the X nor Y-axis is smaller than the zeroLength tolerance. Same as .IsValid

Returns: bool

this.IsLine

Full Usage: this.IsLine

Returns: bool
Modifiers: inline

Tests if one of the X and Y axes is smaller than the zeroLength tolerance.

Returns: bool

this.IsPoint

Full Usage: this.IsPoint

Returns: bool
Modifiers: inline

Tests if all sides are smaller than the zeroLength tolerance. Same as b.IsZero.

Returns: bool

this.IsValid

Full Usage: this.IsValid

Returns: bool
Modifiers: inline

Tests if neither the X nor Y-axis is smaller than the zeroLength tolerance. Same as .HasArea

Returns: bool

this.IsZero

Full Usage: this.IsZero

Returns: bool
Modifiers: inline

Tests if all sides are smaller than the zeroLength tolerance. Same as b.IsPoint.

Returns: bool

this.LongestEdge

Full Usage: this.LongestEdge

Returns: float
Modifiers: inline

Returns the longest edge of the Rect2D.

Returns: float

this.LongestEdgeSq

Full Usage: this.LongestEdgeSq

Returns: float
Modifiers: inline

Returns the square length of longest edge of the Rect2D.

Returns: float

this.Move

Full Usage: this.Move

Parameters:
Returns: Rect2D
Modifiers: inline

Returns a 2D rectangle moved by a vector in world space. Same as Rect2D.move.

v : Vc
Returns: Rect2D

this.MoveX

Full Usage: this.MoveX

Parameters:
    distance : float

Returns: Rect2D
Modifiers: inline

Returns a 2D rectangle moved by a given distance along the world X-axis. This is not the rectangle's own (possibly rotated) local X-axis, use Rect2D.moveAlongLocalX for that.

distance : float
Returns: Rect2D

this.MoveY

Full Usage: this.MoveY

Parameters:
    distance : float

Returns: Rect2D
Modifiers: inline

Returns a 2D rectangle moved by a given distance along the world Y-axis. This is not the rectangle's own (possibly rotated) local Y-axis, use Rect2D.moveAlongLocalY for that.

distance : float
Returns: Rect2D

this.Origin

Full Usage: this.Origin

Returns: Pt

Creates a 2D Point from r.OriginX and r.OriginY

Returns: Pt

this.Points

Full Usage: this.Points

Returns: Pt[]

Returns the 4 corners of the 2D rectangle in counter-clockwise order, starting at Origin. Returns an array of 4 Points: point 0 then 1, 2 and 3.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Pt[]

this.PointsLooped

Full Usage: this.PointsLooped

Returns: Pt[]

Returns the 4 corners of the 2D rectangle as closed loop in counter-clockwise order, starting at Origin. First and last point are the same. Returns an array of 5 Points: point 0 then 1, 2, 3 and again 0.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Pt[]

this.PointsXYCCW

Full Usage: this.PointsXYCCW

Returns: ResizeArray<float>

Returns the 4 corners of the 2D rectangle as open loop in counter-clockwise order, starting at Origin. Returns a ResizeArray of 8 floats: x and y of point 0, x and y of point 1, x and y of point 2, x and y of point 3.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: ResizeArray<float>

this.PointsXYCW

Full Usage: this.PointsXYCW

Returns: ResizeArray<float>

Returns the 4 corners of the 2D rectangle as open loop in Clockwise order, starting at Origin. Returns a ResizeArray of 8 floats: x and y of point 0, x and y of point 3, x and y of point 2, x and y of point 1.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: ResizeArray<float>

this.PointsXYLoopedCCW

Full Usage: this.PointsXYLoopedCCW

Returns: ResizeArray<float>

Returns the 4 corners of the 2D rectangle as closed loop in counter-clockwise order, starting at Origin. Returns a ResizeArray of 10 floats: x and y of point 0, x and y of point 1, x and y of point 2, x and y of point 3 and again x and y of point 0.

  local
  Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: ResizeArray<float>

this.PointsXYLoopedCW

Full Usage: this.PointsXYLoopedCW

Returns: ResizeArray<float>

Returns the 4 corners of the 2D rectangle as closed loop in Clockwise order, starting at Origin. Returns a ResizeArray of 10 floats: x and y of point 0, x and y of point 3, x and y of point 2, x and y of point 1 and again x and y of point 0.

  local
  Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: ResizeArray<float>

this.Pt0

Full Usage: this.Pt0

Returns: Pt
Modifiers: inline

Returns point 0 of the 2D rectangle. Same as member rect.Origin.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Pt

this.Pt1

Full Usage: this.Pt1

Returns: Pt
Modifiers: inline

Returns point 1 of the 2D rectangle.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Pt

this.Pt2

Full Usage: this.Pt2

Returns: Pt
Modifiers: inline

Returns point 2 of the 2D rectangle. Same as rect.FarCorner.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Pt

this.Pt3

Full Usage: this.Pt3

Returns: Pt
Modifiers: inline

Returns point 3 of the 2D rectangle.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Pt

this.Rotate

Full Usage: this.Rotate

Parameters:
Returns: Rect2D
Modifiers: inline

Rotates the 2D rectangle around the World Origin. Same as Rect2D.rotate.

rot : Rotation2D
Returns: Rect2D

this.RotateAround

Full Usage: this.RotateAround

Parameters:
    cen : Pt - The center point of the rotation.
    rot : Rotation2D - The rotation to apply.

Returns: Rect2D The rotated 2D rectangle.
Modifiers: inline

Rotates the 2D rectangle counter-clockwise around a given center point by a Rotation2D. Same as Rect2D.rotateAround.

cen : Pt

The center point of the rotation.

rot : Rotation2D

The rotation to apply.

Returns: Rect2D

The rotated 2D rectangle.

this.RotateDegrees

Full Usage: this.RotateDegrees

Parameters:
    angDegree : float - The rotation angle in degrees.

Returns: Rect2D The rotated 2D rectangle.
Modifiers: inline

Rotates the 2D rectangle counter-clockwise around the World Origin by an angle in degrees.

For better performance precompute the Rotation2D struct and rotate with this.Rotate(rotation2D).

angDegree : float

The rotation angle in degrees.

Returns: Rect2D

The rotated 2D rectangle.

this.RotateDegreesAround

Full Usage: this.RotateDegreesAround

Parameters:
    cen : Pt - The center point of the rotation.
    angDegree : float - The rotation angle in degrees.

Returns: Rect2D The rotated 2D rectangle.
Modifiers: inline

Rotates the 2D rectangle counter-clockwise around a given center point by an angle in degrees.

cen : Pt

The center point of the rotation.

angDegree : float

The rotation angle in degrees.

Returns: Rect2D

The rotated 2D rectangle.

this.RotateOrientation180

Full Usage: this.RotateOrientation180

Returns: Rect2D

Returns the rectangle rotated 180 degrees around its center. Returns the same rectangle with a new orientation rotated by 180 degrees around its center. This only changes the internal representation of the rectangle, the appearance is not changed. Origin will be at point 2, X-axis to point 3, Y-axis to point 1.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Rect2D

this.RotateOrientation90CCW

Full Usage: this.RotateOrientation90CCW

Returns: Rect2D

Returns the same rectangle with a new orientation rotated by 90 degrees counter-clockwise around its center. This only changes the internal representation of the rectangle, the appearance is not changed. Origin will be at point 1, X-axis to point 2, Y-axis to point 0.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Rect2D

this.RotateOrientation90CW

Full Usage: this.RotateOrientation90CW

Returns: Rect2D

Returns the same rectangle with a new orientation rotated by 90 degrees clockwise around its center. This only changes the internal representation of the rectangle, the appearance is not changed. Origin will be at point 3, X-axis to point 0, Y-axis to point 2.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Rect2D

this.RotateRadians

Full Usage: this.RotateRadians

Parameters:
    angRadians : float - The rotation angle in radians.

Returns: Rect2D The rotated 2D rectangle.
Modifiers: inline

Rotates the 2D rectangle counter-clockwise around the World Origin by an angle in radians.

For better performance precompute the Rotation2D struct and rotate with this.Rotate(rotation2D).

angRadians : float

The rotation angle in radians.

Returns: Rect2D

The rotated 2D rectangle.

this.RotateRadiansAround

Full Usage: this.RotateRadiansAround

Parameters:
    cen : Pt - The center point of the rotation.
    angRadians : float - The rotation angle in radians.

Returns: Rect2D The rotated 2D rectangle.
Modifiers: inline

Rotates the 2D rectangle counter-clockwise around a given center point by an angle in radians.

cen : Pt

The center point of the rotation.

angRadians : float

The rotation angle in radians.

Returns: Rect2D

The rotated 2D rectangle.

this.Scale

Full Usage: this.Scale

Parameters:
    factor : float

Returns: Rect2D
Modifiers: inline

Scales the 2D rectangle by a given factor. Scale center is World Origin 0,0

factor : float
Returns: Rect2D

this.ScaleOn

Full Usage: this.ScaleOn

Parameters:
    cen : Pt - The center point of the scaling.
    factor : float - The scale factor.

Returns: Rect2D The scaled 2D rectangle.
Modifiers: inline

Scales the 2D rectangle by a given factor around a given center point.

cen : Pt

The center point of the scaling.

factor : float

The scale factor.

Returns: Rect2D

The scaled 2D rectangle.

this.ShortestEdge

Full Usage: this.ShortestEdge

Returns: float
Modifiers: inline

Returns the shortest edge of the Rect2D.

Returns: float

this.ShortestEdgeSq

Full Usage: this.ShortestEdgeSq

Returns: float
Modifiers: inline

Returns the square length of shortest edge of the Rect2D.

Returns: float

this.SizeX

Full Usage: this.SizeX

Returns: float
Modifiers: inline

The size in X direction

Returns: float

this.SizeXSq

Full Usage: this.SizeXSq

Returns: float
Modifiers: inline

The squared size in X direction

Returns: float

this.SizeY

Full Usage: this.SizeY

Returns: float
Modifiers: inline

The size in Y direction

Returns: float

this.SizeYSq

Full Usage: this.SizeYSq

Returns: float
Modifiers: inline

The squared size in Y direction

Returns: float

this.XAxis

Full Usage: this.XAxis

Returns: Vc

Creates a 2D Vector from r.XAxisX and r.XAxisY

Returns: Vc

this.XAxisUnit

Full Usage: this.XAxisUnit

Returns: UnitVc
Modifiers: inline

Creates a unitized version of the local X-axis.

Returns: UnitVc

this.XCorner

Full Usage: this.XCorner

Returns: Pt
Modifiers: inline

Returns the corner at end of X-axis (point 1).

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Pt

this.YAxis

Full Usage: this.YAxis

Returns: Vc

Creates a 2D Vector from r.YAxisX and r.YAxisY

Returns: Vc

this.YAxisUnit

Full Usage: this.YAxisUnit

Returns: UnitVc
Modifiers: inline

Creates a unitized version of the local Y-axis.

Returns: UnitVc

this.YCorner

Full Usage: this.YCorner

Returns: Pt
Modifiers: inline

Returns the corner at end of Y-axis (point 3).

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

Returns: Pt

Static members

Static member Description

Rect2D.area r

Full Usage: Rect2D.area r

Parameters:
Returns: float
Modifiers: inline

Returns the area of the 2D rectangle.

r : Rect2D
Returns: float

Rect2D.asFSharpCode r

Full Usage: Rect2D.asFSharpCode r

Parameters:
Returns: string
Modifiers: inline

Returns an F# code string that recreates the 2D rectangle.

r : Rect2D
Returns: string

Rect2D.asString r

Full Usage: Rect2D.asString r

Parameters:
Returns: string
Modifiers: inline

Returns a concise formatted string representation of the 2D rectangle.

r : Rect2D
Returns: string

Rect2D.center r

Full Usage: Rect2D.center r

Parameters:
Returns: Pt
Modifiers: inline

Returns the center point of the 2D rectangle.

r : Rect2D
Returns: Pt

Rect2D.clipLine line rect

Full Usage: Rect2D.clipLine line rect

Parameters:
    line : Line2D - The finite 2D line to clip with the rectangle.
    rect : Rect2D - The 2D rectangle to clip the line with.

Returns: Line2D The clipped line segment.

Clips a finite 2D line with a 2D rectangle. Same as Rect2D.tryClipLine, but fails if the line does not intersect the rectangle. Use Rect2D.intersectLine to get the parameters instead of the clipped line.

line : Line2D

The finite 2D line to clip with the rectangle.

rect : Rect2D

The 2D rectangle to clip the line with.

Returns: Line2D

The clipped line segment.

Rect2D.closestParameters p r

Full Usage: Rect2D.closestParameters p r

Parameters:
    p : Pt - The point to find the closest parameters for.
    r : Rect2D - The 2D rectangle.

Returns: float * float A tuple of the X and Y parameters, not clamped to the range 0.0 to 1.0.
Modifiers: inline

Returns the X and Y parameters of the closest point on the 2D rectangle to a given point. If the parameters are outside the range of 0.0 to 1.0, the given point is outside the rectangle. Fails if the X- or Y-axis of the rectangle is shorter than 1e-6.

p : Pt

The point to find the closest parameters for.

r : Rect2D

The 2D rectangle.

Returns: float * float

A tuple of the X and Y parameters, not clamped to the range 0.0 to 1.0.

Rect2D.closestPoint p r

Full Usage: Rect2D.closestPoint p r

Parameters:
    p : Pt - The point to find the closest point for.
    r : Rect2D - The 2D rectangle.

Returns: Pt The closest point on or inside the 2D rectangle.
Modifiers: inline

Returns the closest point on the 2D rectangle to a given point. For a point inside the rectangle, this is the point itself, up to floating-point rounding. A point outside the rectangle is clamped onto its edge. Fails if the X- or Y-axis of the rectangle is shorter than 1e-6.

p : Pt

The point to find the closest point for.

r : Rect2D

The 2D rectangle.

Returns: Pt

The closest point on or inside the 2D rectangle.

Rect2D.containsPt p r

Full Usage: Rect2D.containsPt p r

Parameters:
Returns: bool
Modifiers: inline

Check for point containment in the 2D Rectangle. By doing 4 dot products with the sides of the rectangle. A point exactly on the edge of the rectangle is considered inside.

p : Pt
r : Rect2D
Returns: bool

Rect2D.containsXY x y r

Full Usage: Rect2D.containsXY x y r

Parameters:
    x : float
    y : float
    r : Rect2D

Returns: bool
Modifiers: inline

Check for point containment in the 2D Rectangle. By doing 4 dot products with the sides of the rectangle. A point exactly on the edge of the rectangle is considered inside.

x : float
y : float
r : Rect2D
Returns: bool

Rect2D.countZeroSides r

Full Usage: Rect2D.countZeroSides r

Parameters:
Returns: int
Modifiers: inline

Returns the number of sides below zero-length tolerance.

r : Rect2D
Returns: int

Rect2D.createCenteredFromUnitVc sizeX sizeY directionX center

Full Usage: Rect2D.createCenteredFromUnitVc sizeX sizeY directionX center

Parameters:
    sizeX : float
    sizeY : float
    directionX : UnitVc
    center : Pt

Returns: Rect2D

Creates a 2D rectangle from the X and the Y size, the X direction and a center point. Fails on negative sizes.

sizeX : float
sizeY : float
directionX : UnitVc
center : Pt
Returns: Rect2D

Rect2D.createCenteredFromVc sizeY x center

Full Usage: Rect2D.createCenteredFromVc sizeY x center

Parameters:
    sizeY : float
    x : Vc
    center : Pt

Returns: Rect2D

Creates a 2D rectangle from the Y size, the X vector and a center point. The length of the X vector defines the X size, sizeY defines the absolute Y size. Fails on negative Y size.

sizeY : float
x : Vc
center : Pt
Returns: Rect2D

Rect2D.createFrom3Pts origin xPt yPt

Full Usage: Rect2D.createFrom3Pts origin xPt yPt

Parameters:
    origin : Pt
    xPt : Pt
    yPt : Pt

Returns: Rect2D

Creates a 2D rectangle from three points. Fails if points are too close to each other or all collinear. The Origin, a point in X-axis direction and length, and a point for the length in Y-axis direction. Origin and x-point define the X-axis orientation of the Rectangle. The y-point only defines the length and side of the Y-axis. If the y-point is on the left side of the X-axis the origin will be at point 0, X at point 1. If the y-point is on the right side of the X-axis, the X-axis will be reversed. the origin will be at point x, and the end of the X-axis at the origin. E.G if called with points (origin=3,x=2,y=0) the origin will be at 2, X at 3, and y at 1.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

origin : Pt
xPt : Pt
yPt : Pt
Returns: Rect2D

Rect2D.createFromBounds (minX, minY, maxX, maxY)

Full Usage: Rect2D.createFromBounds (minX, minY, maxX, maxY)

Parameters:
    minX : float
    minY : float
    maxX : float
    maxY : float

Returns: Rect2D

Create a 2D rectangle from an axis-aligned 2D Bounds given as minX, minY, maxX, maxY.

minX : float
minY : float
maxX : float
maxY : float
Returns: Rect2D

Rect2D.createFromLine offRight offLeft line

Full Usage: Rect2D.createFromLine offRight offLeft line

Parameters:
    offRight : float
    offLeft : float
    line : Line2D

Returns: Rect2D

Create a 2D rectangle from a right and left offset and a 2D line. The left offset is in the direction of the future Y-axis.

offRight : float
offLeft : float
line : Line2D
Returns: Rect2D

Rect2D.createFromPtsAndVc dirX pts

Full Usage: Rect2D.createFromPtsAndVc dirX pts

Parameters:
Returns: Rect2D

Finds the oriented bounding rectangle of a set of points. The orientation of the X-axis is defined by the direction vector.

dirX : Vc
pts : IList<Pt>
Returns: Rect2D

Rect2D.createFromUnitVc sizeX sizeY directionX origin

Full Usage: Rect2D.createFromUnitVc sizeX sizeY directionX origin

Parameters:
    sizeX : float
    sizeY : float
    directionX : UnitVc
    origin : Pt

Returns: Rect2D

Creates a 2D rectangle from the size in X and Y direction, the X direction as unit-vector and an origin point. Fails on negative sizes.

sizeX : float
sizeY : float
directionX : UnitVc
origin : Pt
Returns: Rect2D

Rect2D.createFromVc sizeY x origin

Full Usage: Rect2D.createFromVc sizeY x origin

Parameters:
    sizeY : float
    x : Vc
    origin : Pt

Returns: Rect2D

Creates a 2D rectangle from the Y size, the X vector and an origin point. The length of the X vector defines the X size, sizeY defines the absolute Y size. Fails on negative Y size.

sizeY : float
x : Vc
origin : Pt
Returns: Rect2D

Rect2D.createFromVcs x y origin

Full Usage: Rect2D.createFromVcs x y origin

Parameters:
Returns: Rect2D

Create a 2D rectangle from an x-edge, an y-edge and the origin point. Fails if x and y are not in counter-clockwise order. Fails if x and y are not perpendicular. Fails on vectors shorter than 1e-6.

x : Vc
y : Vc
origin : Pt
Returns: Rect2D

Rect2D.createFromVcsUnchecked (origin, x, y)

Full Usage: Rect2D.createFromVcsUnchecked (origin, x, y)

Parameters:
Returns: Rect2D
Modifiers: inline

Create a 2D rectangle from the origin point and X-edge and Y edge. Does not check for counter-clockwise order of x and y. Does not check for perpendicularity.

origin : Pt
x : Vc
y : Vc
Returns: Rect2D

Rect2D.createUnchecked (originX, originY, xaxisX, xaxisY, yaxisX, yaxisY)

Full Usage: Rect2D.createUnchecked (originX, originY, xaxisX, xaxisY, yaxisX, yaxisY)

Parameters:
    originX : float
    originY : float
    xaxisX : float
    xaxisY : float
    yaxisX : float
    yaxisY : float

Returns: Rect2D
Modifiers: inline

Create a 2D rectangle from the origin point and X-edge and Y edge. Does not check for counter-clockwise order of x and y. Does not check for perpendicularity.

originX : float
originY : float
xaxisX : float
xaxisY : float
yaxisX : float
yaxisY : float
Returns: Rect2D

Rect2D.diagonal r

Full Usage: Rect2D.diagonal r

Parameters:
Returns: Vc
Modifiers: inline

Returns the diagonal vector of the 2D rectangle.

r : Rect2D
Returns: Vc

Rect2D.diagonalLine r

Full Usage: Rect2D.diagonalLine r

Parameters:
Returns: Line2D
Modifiers: inline

Returns the diagonal line from point 0 to point 2 of the 2D rectangle.

r : Rect2D
Returns: Line2D

Rect2D.edge01 r

Full Usage: Rect2D.edge01 r

Parameters:
Returns: Line2D
Modifiers: inline

Returns edge 0-1 of the 2D rectangle.

r : Rect2D
Returns: Line2D

Rect2D.edge03 r

Full Usage: Rect2D.edge03 r

Parameters:
Returns: Line2D
Modifiers: inline

Returns edge 0-3 of the 2D rectangle. This is the reverse of Edge30.

r : Rect2D
Returns: Line2D

Rect2D.edge10 r

Full Usage: Rect2D.edge10 r

Parameters:
Returns: Line2D
Modifiers: inline

Returns edge 1-0 of the 2D rectangle. This is the reverse of Edge01.

r : Rect2D
Returns: Line2D

Rect2D.edge12 r

Full Usage: Rect2D.edge12 r

Parameters:
Returns: Line2D
Modifiers: inline

Returns edge 1-2 of the 2D rectangle.

r : Rect2D
Returns: Line2D

Rect2D.edge21 r

Full Usage: Rect2D.edge21 r

Parameters:
Returns: Line2D
Modifiers: inline

Returns edge 2-1 of the 2D rectangle. This is the reverse of Edge12.

r : Rect2D
Returns: Line2D

Rect2D.edge23 r

Full Usage: Rect2D.edge23 r

Parameters:
Returns: Line2D
Modifiers: inline

Returns edge 2-3 of the 2D rectangle.

r : Rect2D
Returns: Line2D

Rect2D.edge30 r

Full Usage: Rect2D.edge30 r

Parameters:
Returns: Line2D
Modifiers: inline

Returns edge 3-0 of the 2D rectangle.

r : Rect2D
Returns: Line2D

Rect2D.edge32 r

Full Usage: Rect2D.edge32 r

Parameters:
Returns: Line2D
Modifiers: inline

Returns edge 3-2 of the 2D rectangle. This is the reverse of Edge23.

r : Rect2D
Returns: Line2D

Rect2D.edgeX r

Full Usage: Rect2D.edgeX r

Parameters:
Returns: Line2D
Modifiers: inline

Returns the local X edge of the 2D rectangle.

r : Rect2D
Returns: Line2D

Rect2D.edgeY r

Full Usage: Rect2D.edgeY r

Parameters:
Returns: Line2D
Modifiers: inline

Returns the local Y edge of the 2D rectangle.

r : Rect2D
Returns: Line2D

Rect2D.edges r

Full Usage: Rect2D.edges r

Parameters:
Returns: Line2D[]
Modifiers: inline

Returns the 4 edges of the 2D rectangle.

r : Rect2D
Returns: Line2D[]

Rect2D.equalsExact a b

Full Usage: Rect2D.equalsExact a b

Parameters:
Returns: bool
Modifiers: inline

Checks if two 2D rectangles are exactly equal. Compares each field with the = operator, so a NaN value is never equal.

a : Rect2D
b : Rect2D
Returns: bool

Rect2D.equalsWithin tol a b

Full Usage: Rect2D.equalsWithin tol a b

Parameters:
Returns: bool

Checks if two 2D rectangles are equal within tolerance. Does not recognize congruent rectangles with different rotation as equal. The tolerance applies to each coordinate of the origin and of the axis vectors separately, not to the Euclidean distance between them. Use Rect2D.equalsExact to check for an exact match.

tol : float
a : Rect2D
b : Rect2D
Returns: bool

Rect2D.evaluateAt xParameter yParameter r

Full Usage: Rect2D.evaluateAt xParameter yParameter r

Parameters:
    xParameter : float
    yParameter : float
    r : Rect2D

Returns: Pt
Modifiers: inline

Evaluates X and Y parameters on the 2D rectangle and returns a point.

xParameter : float
yParameter : float
r : Rect2D
Returns: Pt

Rect2D.evaluateDistance xDistance yDistance r

Full Usage: Rect2D.evaluateDistance xDistance yDistance r

Parameters:
    xDistance : float
    yDistance : float
    r : Rect2D

Returns: Pt
Modifiers: inline

Evaluates a point by X and Y distances along local axes of the 2D rectangle.

xDistance : float
yDistance : float
r : Rect2D
Returns: Pt

Rect2D.expand dist r

Full Usage: Rect2D.expand dist r

Parameters:
Returns: Rect2D

Returns the 2D rectangle expanded by distance on all four sides. Does check for underflow if distance is negative and raises EuclidException.

dist : float
r : Rect2D
Returns: Rect2D

Rect2D.expandRelative factor r

Full Usage: Rect2D.expandRelative factor r

Parameters:
Returns: Rect2D

Returns the 2D-rectangle expanded by a relative factor on all four sides. Values between 0.0 and 1.0 shrink the rectangle. Values larger than 1.0 expand the rectangle. Does check for underflow if factor is negative and raises EuclidException.

factor : float
r : Rect2D
Returns: Rect2D

Rect2D.expandRelativeXY factorX factorY r

Full Usage: Rect2D.expandRelativeXY factorX factorY r

Parameters:
    factorX : float
    factorY : float
    r : Rect2D

Returns: Rect2D

Returns the 2D-rectangle expanded by a relative factor on all four sides. Values between 0.0 and 1.0 shrink the rectangle. Values larger than 1.0 expand the rectangle. Does check for underflow if factor is negative and raises EuclidException.

factorX : float
factorY : float
r : Rect2D
Returns: Rect2D

Rect2D.expandXY distX distY r

Full Usage: Rect2D.expandXY distX distY r

Parameters:
    distX : float
    distY : float
    r : Rect2D

Returns: Rect2D

Returns the 2D rectangle expanded by respective distances on all four sides. Does check for overflow if distance is negative and fails. distX, distY are for the local X- and Y-axis respectively.

distX : float
distY : float
r : Rect2D
Returns: Rect2D

Rect2D.farCorner r

Full Usage: Rect2D.farCorner r

Parameters:
Returns: Pt
Modifiers: inline

Returns the far corner (point 2) of the 2D rectangle.

r : Rect2D
Returns: Pt

Rect2D.fitToPoints pts refRect

Full Usage: Rect2D.fitToPoints pts refRect

Parameters:
Returns: Rect2D

Creates a new 2D rectangle( = oriented bounding rectangle ) to contain the projections of all given points. But not the corners of the reference rectangle. Keeps the same X- and Y-axis orientation as the input rectangle.

pts : IList<Pt>
refRect : Rect2D
Returns: Rect2D

Rect2D.fitToPointsXY xys refRect

Full Usage: Rect2D.fitToPointsXY xys refRect

Parameters:
    xys : IList<float> - The points given as a flat list of coordinates [x0, y0, x1, y1, ...].
    refRect : Rect2D - The reference rectangle to use for orientation.

Returns: Rect2D

Creates a new 2D rectangle( = oriented bounding rectangle ) to contain the projections of all given points. But not the corners of the reference rectangle. Keeps the same X- and Y-axis orientation as the input rectangle.

xys : IList<float>

The points given as a flat list of coordinates [x0, y0, x1, y1, ...].

refRect : Rect2D

The reference rectangle to use for orientation.

Returns: Rect2D

Rect2D.getEdge i r

Full Usage: Rect2D.getEdge i r

Parameters:
Returns: Line2D
Modifiers: inline

Returns one edge of the 2D rectangle by index 0..3.

i : int
r : Rect2D
Returns: Line2D

Rect2D.grid xCount yCount rect

Full Usage: Rect2D.grid xCount yCount rect

Parameters:
    xCount : int
    yCount : int
    rect : Rect2D

Returns: Pt[][]

Divides a 2D rectangle into a grid of points. The points are returned as an array of arrays. A xCount and yCount of 2 will only return just the 4 corners of the rectangle. A xCount and yCount of 3 will return 9 points, including the 4 corners, the 4 mid points on the edges and the center.

xCount : int
yCount : int
rect : Rect2D
Returns: Pt[][]

Rect2D.gridMaxLength xMaxLen yMaxLen rect

Full Usage: Rect2D.gridMaxLength xMaxLen yMaxLen rect

Parameters:
    xMaxLen : float
    yMaxLen : float
    rect : Rect2D

Returns: Pt array array

Divides a 2D rectangle into a grid of points. It will create as few as points as possible respecting the maximum segment length. The input maxSegmentLength is multiplied by factor 1.00001 to avoid numerical errors. That means in an edge case there are fewer segments returned, not more. The returned array is divided along the X-axis. The sub-array is divided along the Y-axis.

xMaxLen : float
yMaxLen : float
rect : Rect2D
Returns: Pt array array

Rect2D.gridMinLength xMinLen yMinLen rect

Full Usage: Rect2D.gridMinLength xMinLen yMinLen rect

Parameters:
    xMinLen : float
    yMinLen : float
    rect : Rect2D

Returns: Pt array array

Divides a 2D rectangle into a grid of points. It will create as many points as possible respecting the minimum side length for x and y. The input minSegmentLength is multiplied by factor 0.9999 of to avoid numerical errors. That means in an edge case there are more segments returned, not fewer. The returned array is divided along the X-axis. The sub-array is divided along the Y-axis.

xMinLen : float
yMinLen : float
rect : Rect2D
Returns: Pt array array

Rect2D.hasArea r

Full Usage: Rect2D.hasArea r

Parameters:
Returns: bool
Modifiers: inline

Returns TRUE if the 2D rectangle has area.

r : Rect2D
Returns: bool

Rect2D.intersectLine line rect

Full Usage: Rect2D.intersectLine line rect

Parameters:
    line : Line2D - The finite 2D line to intersect with the rectangle.
    rect : Rect2D - The 2D rectangle to intersect with the line.

Returns: float * float The entry and exit parameters on the line (tEntry, tExit), clamped to the range 0.0 to 1.0.

Intersects a finite 2D line with a 2D rectangle. Same as Rect2D.tryIntersectLine, but fails if the line does not intersect the rectangle. Use Rect2D.clipLine to get the clipped line instead of the parameters.

line : Line2D

The finite 2D line to intersect with the rectangle.

rect : Rect2D

The 2D rectangle to intersect with the line.

Returns: float * float

The entry and exit parameters on the line (tEntry, tExit), clamped to the range 0.0 to 1.0.

Rect2D.intersectRay ray rect

Full Usage: Rect2D.intersectRay ray rect

Parameters:
    ray : Line2D - The 2D line considered infinite, to intersect with the rectangle.
    rect : Rect2D - The 2D rectangle to intersect with the line.

Returns: float * float The entry and exit parameters on the ray (tEntry, tExit).

Intersects an infinite ray (Line2D extended infinitely in both directions) with a 2D rectangle. Same as Rect2D.tryIntersectRay, but fails if the ray does not intersect the rectangle or if the ray direction is too short. A parameter of 0.0 corresponds to the ray's From point, 1.0 to its To point.

ray : Line2D

The 2D line considered infinite, to intersect with the rectangle.

rect : Rect2D

The 2D rectangle to intersect with the line.

Returns: float * float

The entry and exit parameters on the ray (tEntry, tExit).

Rect2D.isLine r

Full Usage: Rect2D.isLine r

Parameters:
Returns: bool
Modifiers: inline

Returns TRUE if exactly one side is below zero-length tolerance.

r : Rect2D
Returns: bool

Rect2D.isPoint r

Full Usage: Rect2D.isPoint r

Parameters:
Returns: bool
Modifiers: inline

Returns TRUE if the 2D rectangle degenerates to a point. Same as Rect2D.isZero.

r : Rect2D
Returns: bool

Rect2D.isValid r

Full Usage: Rect2D.isValid r

Parameters:
Returns: bool
Modifiers: inline

Returns TRUE if both sides are above zero-length tolerance.

r : Rect2D
Returns: bool

Rect2D.isZero r

Full Usage: Rect2D.isZero r

Parameters:
Returns: bool
Modifiers: inline

Returns TRUE if all sides are below zero-length tolerance. Same as Rect2D.isPoint.

r : Rect2D
Returns: bool

Rect2D.iterPointsCCW action r

Full Usage: Rect2D.iterPointsCCW action r

Parameters:
    action : float -> float -> unit - The action to call 4 times . Once for each corner, with x and y as parameters.
    r : Rect2D - The rectangle to iterate the corners of.

Iterates the 4 corners of the 2D rectangle in counter-clockwise order, starting at Origin.

action : float -> float -> unit

The action to call 4 times . Once for each corner, with x and y as parameters.

r : Rect2D

The rectangle to iterate the corners of.

Rect2D.iterPointsCW action r

Full Usage: Rect2D.iterPointsCW action r

Parameters:
    action : float -> float -> unit - The action to call 4 times . Once for each corner, with x and y as parameters.
    r : Rect2D - The rectangle to iterate the corners of.

Iterates the 4 corners of the 2D rectangle in Clockwise order, starting at Origin.

action : float -> float -> unit

The action to call 4 times . Once for each corner, with x and y as parameters.

r : Rect2D

The rectangle to iterate the corners of.

Rect2D.iterPointsLoopedCCW action r

Full Usage: Rect2D.iterPointsLoopedCCW action r

Parameters:
    action : float -> float -> unit - The action to call 5 times. With x and y as parameters.
    r : Rect2D - The rectangle to iterate the corners of.

Iterates the 4 corners of the 2D rectangle as closed loop in counter-clockwise order, starting and ending at Origin.

action : float -> float -> unit

The action to call 5 times. With x and y as parameters.

r : Rect2D

The rectangle to iterate the corners of.

Rect2D.iterPointsLoopedCW action r

Full Usage: Rect2D.iterPointsLoopedCW action r

Parameters:
    action : float -> float -> unit - The action to call 5 times. With x and y as parameters.
    r : Rect2D - The rectangle to iterate the corners of.

Iterates the 4 corners of the 2D rectangle as closed loop in Clockwise order, starting and ending at Origin.

action : float -> float -> unit

The action to call 5 times. With x and y as parameters.

r : Rect2D

The rectangle to iterate the corners of.

Rect2D.longestEdge r

Full Usage: Rect2D.longestEdge r

Parameters:
Returns: float
Modifiers: inline

Returns the longest edge length of the 2D rectangle.

r : Rect2D
Returns: float

Rect2D.longestEdgeSq r

Full Usage: Rect2D.longestEdgeSq r

Parameters:
Returns: float
Modifiers: inline

Returns the squared length of the longest edge of the 2D rectangle.

r : Rect2D
Returns: float

Rect2D.move v r

Full Usage: Rect2D.move v r

Parameters:
Returns: Rect2D

Translate by a 2D vector in world space. (Same as Rect2D.Move)

v : Vc
r : Rect2D
Returns: Rect2D

Rect2D.moveAlongLocalX distX r

Full Usage: Rect2D.moveAlongLocalX distX r

Parameters:
Returns: Rect2D

Translate along the local X-axis of the 2D Rectangle.

distX : float
r : Rect2D
Returns: Rect2D

Rect2D.moveAlongLocalY distY r

Full Usage: Rect2D.moveAlongLocalY distY r

Parameters:
Returns: Rect2D

Translate along the local Y-axis of the 2D Rectangle.

distY : float
r : Rect2D
Returns: Rect2D

Rect2D.moveX distance r

Full Usage: Rect2D.moveX distance r

Parameters:
Returns: Rect2D
Modifiers: inline

Returns a 2D rectangle moved by a given distance along the world X-axis. This is not the rectangle's own (possibly rotated) local X-axis, use Rect2D.moveAlongLocalX for that.

distance : float
r : Rect2D
Returns: Rect2D

Rect2D.moveY distance r

Full Usage: Rect2D.moveY distance r

Parameters:
Returns: Rect2D
Modifiers: inline

Returns a 2D rectangle moved by a given distance along the world Y-axis. This is not the rectangle's own (possibly rotated) local Y-axis, use Rect2D.moveAlongLocalY for that.

distance : float
r : Rect2D
Returns: Rect2D

Rect2D.notEqualsWithin tol a b

Full Usage: Rect2D.notEqualsWithin tol a b

Parameters:
Returns: bool

Check if two 2D rectangles are not equal within a given tolerance. The tolerance applies to each coordinate of the origin and of the axis vectors separately, not to the Euclidean distance between them.

tol : float
a : Rect2D
b : Rect2D
Returns: bool

Rect2D.offset dist rect

Full Usage: Rect2D.offset dist rect

Parameters:
Returns: Rect2D

Offset a Rect2D inwards by a given distance. A negative distance will offset outwards. Fails if the distance is larger than half the size of the rectangle.

dist : float
rect : Rect2D
Returns: Rect2D

Rect2D.offsetCorner (rect, corner, xOffset, yOffset, xWidth, yHeight)

Full Usage: Rect2D.offsetCorner (rect, corner, xOffset, yOffset, xWidth, yHeight)

Parameters:
    rect : Rect2D - The 2D rectangle
    corner : int - The Index of the corner to offset
       local
       Y-axis
       ^
       |
       |             2
     3 +------------+
       |            |
       |            |
       |            |
       |            |
       |            |       local
       +------------+-----> X-axis
      0-Origin       1
    

    xOffset : float - The local offset distances in x direction. (Applies to the y side.) Positive values offset to the inside of the rectangle, negative values will offset outwards.
    yOffset : float - The local offset distances in y direction. (Applies to the x side.) Positive values offset to the inside of the rectangle, negative values will offset outwards.
    xWidth : float - The width (or size in x direction) that will be added to the current offset.
    yHeight : float - The height (or size in y direction) that will be added to the current offset.

Returns: Rect2D A new 2D Rectangle. It will always have the same X- and Y-axis orientation as the input rectangle. Independent of negative or positive offsets

Offsets a local Rect2D at one of the four corners.

rect : Rect2D

The 2D rectangle

corner : int

The Index of the corner to offset

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

xOffset : float

The local offset distances in x direction. (Applies to the y side.) Positive values offset to the inside of the rectangle, negative values will offset outwards.

yOffset : float

The local offset distances in y direction. (Applies to the x side.) Positive values offset to the inside of the rectangle, negative values will offset outwards.

xWidth : float

The width (or size in x direction) that will be added to the current offset.

yHeight : float

The height (or size in y direction) that will be added to the current offset.

Returns: Rect2D

A new 2D Rectangle. It will always have the same X- and Y-axis orientation as the input rectangle. Independent of negative or positive offsets

Rect2D.offsetEdge (rect, edgeIdx, offEdge, width, offStart, offEnd)

Full Usage: Rect2D.offsetEdge (rect, edgeIdx, offEdge, width, offStart, offEnd)

Parameters:
    rect : Rect2D - The 2D rectangle
    edgeIdx : int - The Index of the edge to offset
       local
       Y-axis
       ^
       |
       |      2
       +------------+
       |            |
       |            |
      3|            |1
       |            |
       |            |       local
       +------------+-----> X-axis
             0
    

    offEdge : float - The local offset distances parallel to the edge.
    width : float - The width of the new rectangle. This is like the second offset to be applied to the first offset of offEdge
    offStart : float - The local offset distances perpendicular to the edge at the start.
    offEnd : float - The local offset distances perpendicular to the edge at the end.

Returns: Rect2D A new 2D Rectangle. It will always have the same X- and Y-axis orientation as the input rectangle. Independent of negative or positive offsets

Offsets a local Rect2D at one of the four edges.

rect : Rect2D

The 2D rectangle

edgeIdx : int

The Index of the edge to offset

   local
   Y-axis
   ^
   |
   |      2
   +------------+
   |            |
   |            |
  3|            |1
   |            |
   |            |       local
   +------------+-----> X-axis
         0

offEdge : float

The local offset distances parallel to the edge.

width : float

The width of the new rectangle. This is like the second offset to be applied to the first offset of offEdge

offStart : float

The local offset distances perpendicular to the edge at the start.

offEnd : float

The local offset distances perpendicular to the edge at the end.

Returns: Rect2D

A new 2D Rectangle. It will always have the same X- and Y-axis orientation as the input rectangle. Independent of negative or positive offsets

Rect2D.offsetVariable dist rect

Full Usage: Rect2D.offsetVariable dist rect

Parameters:
    dist : float[]
    rect : Rect2D

Returns: Rect2D

Offset a Rect2D inwards by four distances. Negative distances will offset outwards. The distance array is for Edge01, Edge12, Edge23, and Edge30 respectively. Fails if the distance is larger than half the size of the rectangle.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

dist : float[]
rect : Rect2D
Returns: Rect2D

Rect2D.origin r

Full Usage: Rect2D.origin r

Parameters:
Returns: Pt
Modifiers: inline

Creates a 2D Point from r.OriginX and r.OriginY

r : Rect2D
Returns: Pt

Rect2D.points r

Full Usage: Rect2D.points r

Parameters:
Returns: Pt[]
Modifiers: inline

Returns the 4 corner points of the 2D rectangle.

r : Rect2D
Returns: Pt[]

Rect2D.pointsLooped r

Full Usage: Rect2D.pointsLooped r

Parameters:
Returns: Pt[]
Modifiers: inline

Returns the 4 corner points as a closed loop.

r : Rect2D
Returns: Pt[]

Rect2D.pointsXYCCW r

Full Usage: Rect2D.pointsXYCCW r

Parameters:
Returns: ResizeArray<float>
Modifiers: inline

Returns the 4 corner points of the 2D rectangle as an open loop in counter-clockwise order, starting at Origin. Returns a ResizeArray of 8 floats: x and y of point 0, x and y of point 1, x and y of point 2, x and y of point 3.

r : Rect2D
Returns: ResizeArray<float>

Rect2D.pointsXYCW r

Full Usage: Rect2D.pointsXYCW r

Parameters:
Returns: ResizeArray<float>
Modifiers: inline

Returns the 4 corner points of the 2D rectangle as open loop in Clockwise order, starting at Origin. Returns a ResizeArray of 8 floats: x and y of point 0, x and y of point 3, x and y of point 2, x and y of point 1.

r : Rect2D
Returns: ResizeArray<float>

Rect2D.pointsXYLoopedCCW r

Full Usage: Rect2D.pointsXYLoopedCCW r

Parameters:
Returns: ResizeArray<float>
Modifiers: inline

Returns the 4 corner points as a closed loop in counter-clockwise order, starting at Origin. Returns a ResizeArray of 10 floats: x and y of point 0, x and y of point 1, x and y of point 2, x and y of point 3 and again x and y of point 0.

r : Rect2D
Returns: ResizeArray<float>

Rect2D.pointsXYLoopedCW r

Full Usage: Rect2D.pointsXYLoopedCW r

Parameters:
Returns: ResizeArray<float>
Modifiers: inline

Returns the 4 corner points as a closed loop in Clockwise order, starting at Origin. Returns a ResizeArray of 10 floats: x and y of point 0, x and y of point 3, x and y of point 2, x and y of point 1 and again x and y of point 0.

r : Rect2D
Returns: ResizeArray<float>

Rect2D.pt0 r

Full Usage: Rect2D.pt0 r

Parameters:
Returns: Pt
Modifiers: inline

Returns point 0 of the 2D rectangle.

r : Rect2D
Returns: Pt

Rect2D.pt1 r

Full Usage: Rect2D.pt1 r

Parameters:
Returns: Pt
Modifiers: inline

Returns point 1 of the 2D rectangle.

r : Rect2D
Returns: Pt

Rect2D.pt2 r

Full Usage: Rect2D.pt2 r

Parameters:
Returns: Pt
Modifiers: inline

Returns point 2 of the 2D rectangle.

r : Rect2D
Returns: Pt

Rect2D.pt3 r

Full Usage: Rect2D.pt3 r

Parameters:
Returns: Pt
Modifiers: inline

Returns point 3 of the 2D rectangle.

r : Rect2D
Returns: Pt

Rect2D.rotate rot rect

Full Usage: Rect2D.rotate rot rect

Parameters:
Returns: Rect2D

Rotation of a Rect2D.

rot : Rotation2D
rect : Rect2D
Returns: Rect2D

Rect2D.rotateAround cen rot rect

Full Usage: Rect2D.rotateAround cen rot rect

Parameters:
    cen : Pt - The center point of the rotation.
    rot : Rotation2D - The rotation to apply.
    rect : Rect2D - The 2D rectangle to rotate.

Returns: Rect2D The rotated 2D rectangle.

Rotates a 2D rectangle counter-clockwise around a given center point by a Rotation2D.

cen : Pt

The center point of the rotation.

rot : Rotation2D

The rotation to apply.

rect : Rect2D

The 2D rectangle to rotate.

Returns: Rect2D

The rotated 2D rectangle.

Rect2D.rotateDegrees angDegree r

Full Usage: Rect2D.rotateDegrees angDegree r

Parameters:
    angDegree : float - The rotation angle in degrees.
    r : Rect2D - The 2D rectangle to rotate.

Returns: Rect2D The rotated 2D rectangle.
Modifiers: inline

Rotates a 2D rectangle counter-clockwise around the World Origin by an angle in degrees.

For better performance precompute the Rotation2D struct and rotate with Rect2D.rotate.

angDegree : float

The rotation angle in degrees.

r : Rect2D

The 2D rectangle to rotate.

Returns: Rect2D

The rotated 2D rectangle.

Rect2D.rotateDegreesAround cen angDegree r

Full Usage: Rect2D.rotateDegreesAround cen angDegree r

Parameters:
    cen : Pt - The center point of the rotation.
    angDegree : float - The rotation angle in degrees.
    r : Rect2D - The 2D rectangle to rotate.

Returns: Rect2D The rotated 2D rectangle.
Modifiers: inline

Rotates a 2D rectangle counter-clockwise around a given center point by an angle in degrees.

cen : Pt

The center point of the rotation.

angDegree : float

The rotation angle in degrees.

r : Rect2D

The 2D rectangle to rotate.

Returns: Rect2D

The rotated 2D rectangle.

Rect2D.rotateOrientation180 r

Full Usage: Rect2D.rotateOrientation180 r

Parameters:
Returns: Rect2D
Modifiers: inline

Returns the same rectangle with orientation rotated 180 degrees around center.

r : Rect2D
Returns: Rect2D

Rect2D.rotateOrientation90CCW r

Full Usage: Rect2D.rotateOrientation90CCW r

Parameters:
Returns: Rect2D
Modifiers: inline

Returns the same rectangle with orientation rotated 90 degrees counter-clockwise around center.

r : Rect2D
Returns: Rect2D

Rect2D.rotateOrientation90CW r

Full Usage: Rect2D.rotateOrientation90CW r

Parameters:
Returns: Rect2D
Modifiers: inline

Returns the same rectangle with orientation rotated 90 degrees clockwise around center.

r : Rect2D
Returns: Rect2D

Rect2D.rotateRadians angRadians r

Full Usage: Rect2D.rotateRadians angRadians r

Parameters:
    angRadians : float - The rotation angle in radians.
    r : Rect2D - The 2D rectangle to rotate.

Returns: Rect2D The rotated 2D rectangle.
Modifiers: inline

Rotates a 2D rectangle counter-clockwise around the World Origin by an angle in radians.

For better performance precompute the Rotation2D struct and rotate with Rect2D.rotate.

angRadians : float

The rotation angle in radians.

r : Rect2D

The 2D rectangle to rotate.

Returns: Rect2D

The rotated 2D rectangle.

Rect2D.rotateRadiansAround cen angRadians r

Full Usage: Rect2D.rotateRadiansAround cen angRadians r

Parameters:
    cen : Pt - The center point of the rotation.
    angRadians : float - The rotation angle in radians.
    r : Rect2D - The 2D rectangle to rotate.

Returns: Rect2D The rotated 2D rectangle.
Modifiers: inline

Rotates a 2D rectangle counter-clockwise around a given center point by an angle in radians.

cen : Pt

The center point of the rotation.

angRadians : float

The rotation angle in radians.

r : Rect2D

The 2D rectangle to rotate.

Returns: Rect2D

The rotated 2D rectangle.

Rect2D.scale factor r

Full Usage: Rect2D.scale factor r

Parameters:
Returns: Rect2D
Modifiers: inline

Scales the 2D rectangle by a given factor. Scale center is World Origin 0,0

factor : float
r : Rect2D
Returns: Rect2D

Rect2D.scaleOn cen factor r

Full Usage: Rect2D.scaleOn cen factor r

Parameters:
    cen : Pt - The center point of the scaling.
    factor : float - The scale factor.
    r : Rect2D - The 2D rectangle to scale.

Returns: Rect2D The scaled 2D rectangle.
Modifiers: inline

Scales a 2D rectangle by a given factor around a given center point.

cen : Pt

The center point of the scaling.

factor : float

The scale factor.

r : Rect2D

The 2D rectangle to scale.

Returns: Rect2D

The scaled 2D rectangle.

Rect2D.shortestEdge r

Full Usage: Rect2D.shortestEdge r

Parameters:
Returns: float
Modifiers: inline

Returns the shortest edge length of the 2D rectangle.

r : Rect2D
Returns: float

Rect2D.shortestEdgeSq r

Full Usage: Rect2D.shortestEdgeSq r

Parameters:
Returns: float
Modifiers: inline

Returns the squared length of the shortest edge of the 2D rectangle.

r : Rect2D
Returns: float

Rect2D.sizeX r

Full Usage: Rect2D.sizeX r

Parameters:
Returns: float
Modifiers: inline

Returns the size in X direction.

r : Rect2D
Returns: float

Rect2D.sizeXSq r

Full Usage: Rect2D.sizeXSq r

Parameters:
Returns: float
Modifiers: inline

Returns the squared size in X direction.

r : Rect2D
Returns: float

Rect2D.sizeY r

Full Usage: Rect2D.sizeY r

Parameters:
Returns: float
Modifiers: inline

Returns the size in Y direction.

r : Rect2D
Returns: float

Rect2D.sizeYSq r

Full Usage: Rect2D.sizeYSq r

Parameters:
Returns: float
Modifiers: inline

Returns the squared size in Y direction.

r : Rect2D
Returns: float

Rect2D.subDivide xCount yCount xGap yGap rect

Full Usage: Rect2D.subDivide xCount yCount xGap yGap rect

Parameters:
    xCount : int
    yCount : int
    xGap : float
    yGap : float
    rect : Rect2D

Returns: Rect2D array array

Divides a 2D rectangle into a grid of sub-rectangles. The sub-rectangles are returned as an array of arrays. The gap between the sub-rectangles is given in x and y direction. It does not apply to the outer edges of the 2D Rectangle. The returned array has xCount elements, each element is an array of yCount sub-rectangles.

xCount : int
yCount : int
xGap : float
yGap : float
rect : Rect2D
Returns: Rect2D array array

Rect2D.subDivideMaxLength (rect, xMaxLen, yMaxLen, xGap, yGap)

Full Usage: Rect2D.subDivideMaxLength (rect, xMaxLen, yMaxLen, xGap, yGap)

Parameters:
    rect : Rect2D
    xMaxLen : float
    yMaxLen : float
    xGap : float
    yGap : float

Returns: Rect2D array array

Divides a 2D rectangle into a grid of sub-rectangles. The gap between the sub-rectangles is given in x and y direction. It does not apply to the outer edges of the 2D Rectangle. It will create as few as segments as possible respecting the maximum segment length. The input maxSegmentLength is multiplied by factor 1.00001 of to avoid numerical errors. That means in an edge case there are fewer segments returned, not more. The returned array is divided along the X-axis. The sub-array is divided along the Y-axis.

rect : Rect2D
xMaxLen : float
yMaxLen : float
xGap : float
yGap : float
Returns: Rect2D array array

Rect2D.subDivideMinLength (rect, xMinLen, yMinLen, xGap, yGap)

Full Usage: Rect2D.subDivideMinLength (rect, xMinLen, yMinLen, xGap, yGap)

Parameters:
    rect : Rect2D
    xMinLen : float
    yMinLen : float
    xGap : float
    yGap : float

Returns: Rect2D array array

Divides a 2D rectangle into a grid of sub-rectangles. The gap between the sub-rectangles is given in x and y direction. It does not apply to the outer edges of the 2D Rectangle. It will create as many sub-rectangles as possible respecting the minimum side length for x and y. The input minSegmentLength is multiplied by factor 0.9999 of to avoid numerical errors. That means in an edge case there are more segments returned, not fewer. The returned array is divided along the X-axis. The sub-array is divided along the Y-axis.

rect : Rect2D
xMinLen : float
yMinLen : float
xGap : float
yGap : float
Returns: Rect2D array array

Rect2D.tryClipLine line rect

Full Usage: Rect2D.tryClipLine line rect

Parameters:
    line : Line2D - The finite 2D line to clip with the rectangle.
    rect : Rect2D - The 2D rectangle to clip the line with.

Returns: Line2D voption The clipped line segment, or ValueNone if the line does not intersect the rectangle.

Clips a finite 2D line with a 2D rectangle. Returns the part of the line that is inside the rectangle. Use Rect2D.tryIntersectLine to get the parameters instead of the clipped line.

line : Line2D

The finite 2D line to clip with the rectangle.

rect : Rect2D

The 2D rectangle to clip the line with.

Returns: Line2D voption

The clipped line segment, or ValueNone if the line does not intersect the rectangle.

Rect2D.tryCreateFrom3Pts origin xPt yPt

Full Usage: Rect2D.tryCreateFrom3Pts origin xPt yPt

Parameters:
    origin : Pt
    xPt : Pt
    yPt : Pt

Returns: Rect2D voption

Tries to create a 2D rectangle from three points. Returns ValueNone if points are too close to each other or all collinear. The Origin, a point in X-axis direction and length, and a point for the length in Y-axis direction. Origin and x-point define the X-axis orientation of the Rectangle. The y-point only defines the length and side of the Y-axis. If the y-point is on the left side of the X-axis the origin will be at point 0, X at point 1. If the y-point is on the right side of the X-axis, the X-axis will be reversed. the origin will be at point x, and the end of the X-axis at the origin. E.G if called with points (origin=3,x=2,y=0) the origin will be at 2, X at 3, and y at 1.

   local
   Y-axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-axis
  0-Origin       1

origin : Pt
xPt : Pt
yPt : Pt
Returns: Rect2D voption

Rect2D.tryIntersectLine line rect

Full Usage: Rect2D.tryIntersectLine line rect

Parameters:
    line : Line2D - The finite 2D line to intersect with the rectangle.
    rect : Rect2D - The 2D rectangle to intersect with the line.

Returns: (float * float) voption The entry and exit parameters on the line (tEntry, tExit), or ValueNone if the line does not intersect the rectangle.

Intersects a finite 2D line with a 2D rectangle. Returns the parameters of the part of the line that is inside the rectangle, clamped to the range 0.0 to 1.0. A parameter of 0.0 corresponds to the line's From point, 1.0 to its To point. Use Rect2D.tryClipLine to get the clipped line instead of the parameters.

line : Line2D

The finite 2D line to intersect with the rectangle.

rect : Rect2D

The 2D rectangle to intersect with the line.

Returns: (float * float) voption

The entry and exit parameters on the line (tEntry, tExit), or ValueNone if the line does not intersect the rectangle.

Rect2D.tryIntersectRay ray rect

Full Usage: Rect2D.tryIntersectRay ray rect

Parameters:
    ray : Line2D - The 2D line considered infinite, to intersect with the rectangle.
    rect : Rect2D - The 2D rectangle to intersect with the line.

Returns: (float * float) voption A ValueSome with a tuple of (tEntry, tExit) with the entry and exit parameters on the ray. or ValueNone if - The ray does not intersect the rectangle - The ray length is shorter than 1e-6

Intersects an infinite ray (Line2D extended infinitely in both directions) with a 2D rectangle. Uses the slab intersection method in the rectangle's local coordinate system. Returns ValueNone if the ray does not intersect the rectangle or if the ray direction is too short. Returns ValueSome with the entry and exit parameters on the ray if it intersects. A parameter of 0.0 corresponds to the ray's From point, 1.0 to its To point.

ray : Line2D

The 2D line considered infinite, to intersect with the rectangle.

rect : Rect2D

The 2D rectangle to intersect with the line.

Returns: (float * float) voption

A ValueSome with a tuple of (tEntry, tExit) with the entry and exit parameters on the ray. or ValueNone if - The ray does not intersect the rectangle - The ray length is shorter than 1e-6

Rect2D.xAxis r

Full Usage: Rect2D.xAxis r

Parameters:
Returns: Vc
Modifiers: inline

Creates a 2D Vector from r.XAxisX and r.XAxisY

r : Rect2D
Returns: Vc

Rect2D.xAxisUnit r

Full Usage: Rect2D.xAxisUnit r

Parameters:
Returns: UnitVc
Modifiers: inline

Returns the unitized local X-axis of the 2D rectangle.

r : Rect2D
Returns: UnitVc

Rect2D.xCorner r

Full Usage: Rect2D.xCorner r

Parameters:
Returns: Pt
Modifiers: inline

Returns the X corner (point 1) of the 2D rectangle.

r : Rect2D
Returns: Pt

Rect2D.yAxis r

Full Usage: Rect2D.yAxis r

Parameters:
Returns: Vc
Modifiers: inline

Creates a 2D Vector from r.YAxisX and r.YAxisY

r : Rect2D
Returns: Vc

Rect2D.yAxisUnit r

Full Usage: Rect2D.yAxisUnit r

Parameters:
Returns: UnitVc
Modifiers: inline

Returns the unitized local Y-axis of the 2D rectangle.

r : Rect2D
Returns: UnitVc

Rect2D.yCorner r

Full Usage: Rect2D.yCorner r

Parameters:
Returns: Pt
Modifiers: inline

Returns the Y corner (point 3) of the 2D rectangle.

r : Rect2D
Returns: Pt

Type something to start searching.