Header menu logo Euclid

Rect2D Type

 An immutable 2D Rectangle with any rotation in 2D space.
 Described by an Origin and two Edge vectors.
 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

Origin

Full Usage: Origin

Field type: Pt

The Origin Corner of the 2D Rectangle.

Field type: Pt

Xaxis

Full Usage: Xaxis

Field type: Vc

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

Field type: Vc

Yaxis

Full Usage: Yaxis

Field type: Vc

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

Field type: Vc

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.AreaSq

Full Usage: this.AreaSq

Returns: float
Modifiers: inline

Calculates the squared area of the 2D Rectangle. by using the squared lengths of the X and Y axis. This is a bit faster than calculating the area and good enough for relative comparisons or sorting by size.

Returns: float

this.AsString

Full Usage: this.AsString

Returns: string

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

Returns: string

this.BRect

Full Usage: this.BRect

Returns: BRect

Get the axis aligned 2D Bounding Rectangle of the 2D Rectangle.

Returns: BRect

this.Center

Full Usage: this.Center

Returns: Pt
Modifiers: inline

Returns the center of the 2D Rectangle.

Returns: Pt

this.Contains

Full Usage: this.Contains

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 Box is considered inside.

p : Pt
Returns: bool

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.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.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.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 a 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.EvaluateDist

Full Usage: this.EvaluateDist

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).

   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.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 als 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.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.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 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 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 to point 0, Y-axis to point 2.
   local
   Y-Axis
   ^
   |
   |             2
 3 +------------+
   |            |
   |            |
   |            |
   |            |
   |            |       local
   +------------+-----> X-Axis
  0-Origin       1
Returns: Rect2D

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.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.XaxisUnit

Full Usage: this.XaxisUnit

Returns: Vc
Modifiers: inline

Creates a unitized version of the local X-Axis.

Returns: Vc

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

this.YaxisUnit

Full Usage: this.YaxisUnit

Returns: Vc
Modifiers: inline

Creates a unitized version of the local Y-Axis.

Returns: Vc

Static members

Static member Description

Rect2D.contains p r

Full Usage: Rect2D.contains 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 Box is considered inside.

p : Pt
r : Rect2D
Returns: bool

Rect2D.createFrom3Points (origin, xPt, yPt)

Full Usage: Rect2D.createFrom3Points (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 colinear.
 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.createFromBRect b

Full Usage: Rect2D.createFromBRect b

Parameters:
Returns: Rect2D

Give 2D Bounding Rect.

b : BRect
Returns: Rect2D

Rect2D.createFromCenterAndDirection (center, directionX, sizeX, sizeY)

Full Usage: Rect2D.createFromCenterAndDirection (center, directionX, sizeX, sizeY)

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

Returns: Rect2D

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

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

Rect2D.createFromCenterAndVector (center, x, sizeY)

Full Usage: Rect2D.createFromCenterAndVector (center, x, sizeY)

Parameters:
    center : Pt
    x : Vc
    sizeY : float

Returns: Rect2D

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

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

Rect2D.createFromDirAndPoints dirX pts

Full Usage: Rect2D.createFromDirAndPoints 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.createFromDirectionAndSizes (origin, directionX, sizeX, sizeY)

Full Usage: Rect2D.createFromDirectionAndSizes (origin, directionX, sizeX, sizeY)

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

Returns: Rect2D

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

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

Rect2D.createFromLine (line, offRight, offLeft)

Full Usage: Rect2D.createFromLine (line, offRight, offLeft)

Parameters:
    line : Line2D
    offRight : float
    offLeft : float

Returns: Rect2D

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

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

Rect2D.createFromVectors (origin, x, y)

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

Parameters:
Returns: Rect2D

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

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

Rect2D.createFromXVectorAndWidth (origin, x, sizeY)

Full Usage: Rect2D.createFromXVectorAndWidth (origin, x, sizeY)

Parameters:
    origin : Pt
    x : Vc
    sizeY : float

Returns: Rect2D

Creates a 2D rectangle from a origin point, the X vector and Y size. Fails on negative Y size.

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

Rect2D.createUnchecked (origin, x, y)

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

Parameters:
Returns: Rect2D

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.equals tol a b

Full Usage: Rect2D.equals 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. Use a tolerance of 0.0 to check for an exact match of exactly equal rectangles.

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

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.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 six 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.grid (rect, xCount, yCount)

Full Usage: Rect2D.grid (rect, xCount, yCount)

Parameters:
    rect : Rect2D
    xCount : int
    yCount : int

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.

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

Rect2D.gridMaxLength (rect, xMaxLen, yMaxLen)

Full Usage: Rect2D.gridMaxLength (rect, xMaxLen, yMaxLen)

Parameters:
    rect : Rect2D
    xMaxLen : float
    yMaxLen : float

Returns: Pt[][]

Divides a 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.0001 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
Returns: Pt[][]

Rect2D.gridMinLength (rect, xMinLen, yMinLen)

Full Usage: Rect2D.gridMinLength (rect, xMinLen, yMinLen)

Parameters:
    rect : Rect2D
    xMinLen : float
    yMinLen : float

Returns: Pt[][]

Divides a 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.

rect : Rect2D
xMinLen : float
yMinLen : float
Returns: Pt[][]

Rect2D.move v r

Full Usage: Rect2D.move v r

Parameters:
Returns: Rect2D

Translate by a 2D vector.(Same as Rect2D.translate)

v : Vc
r : Rect2D
Returns: Rect2D

Rect2D.notEquals tol a b

Full Usage: Rect2D.notEquals tol a b

Parameters:
Returns: bool

Check if two 2D Rectangles are not equal within a given tolerance. Use a tolerance of 0.0 to check if the two rectangles are not exactly equal.

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 the width (or size in x direction) that will be added to the current offset.
    yHeight : float - The 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 the width (or size in x direction) that will be added to the current offset.

yHeight : float

The 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 corners.

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.offsetVar dist rect

Full Usage: Rect2D.offsetVar 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.rotate rot rect

Full Usage: Rect2D.rotate rot rect

Parameters:
Returns: Rect2D

Rotation of a Rect2D.

rot : Rotation2D
rect : Rect2D
Returns: Rect2D

Rect2D.rotateWithCenter cen rot rect

Full Usage: Rect2D.rotateWithCenter cen rot rect

Parameters:
Returns: Rect2D

Rotation of a Rect2D. around a given Center.

cen : Pt
rot : Rotation2D
rect : Rect2D
Returns: Rect2D

Rect2D.subDivide (rect, xCount, yCount, xGap, yGap)

Full Usage: Rect2D.subDivide (rect, xCount, yCount, xGap, yGap)

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

Returns: Rect2D[][]

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.

rect : Rect2D
xCount : int
yCount : int
xGap : float
yGap : float
Returns: Rect2D[][]

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[][]

Divides a 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[][]

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[][]

Divides a 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[][]

Rect2D.translate v r

Full Usage: Rect2D.translate v r

Parameters:
Returns: Rect2D

Translate by a 2D vector.(Same as Rect2D.move)

v : Vc
r : Rect2D
Returns: Rect2D

Rect2D.translateX distX r

Full Usage: Rect2D.translateX distX r

Parameters:
Returns: Rect2D

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

distX : float
r : Rect2D
Returns: Rect2D

Rect2D.translateY distY r

Full Usage: Rect2D.translateY distY r

Parameters:
Returns: Rect2D

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

distY : float
r : Rect2D
Returns: Rect2D

Rect2D.tryCreateFrom3Points (origin, xPt, yPt)

Full Usage: Rect2D.tryCreateFrom3Points (origin, xPt, yPt)

Parameters:
    origin : Pt
    xPt : Pt
    yPt : Pt

Returns: Rect2D option
 Tries to create a 2D rectangle from three points. Returns None if points are too close to each other or all colinear.
 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 option

Type something to start searching.