The Rectangle3d type is an extension of Rectangle2d that exists in 3D.
In most cases it will be most convenient to create a Rectangle3d by creating
a Rectangle2d on a particular SketchPlane3d, using Rectangle3d.on.
This module then contains functionality for:
Construct a 3D rectangle lying on a sketch plane by providing a 2D rectangle specified in XY coordinates within the sketch plane. For example, to create a 3D rectangle lying on the YZ plane:
rectangle =
Rectangle3d.on SketchPlane3d.yz <|
Rectangle2d.from
(Point2d.meters 1 2)
(Point2d.meters 3 4)
Rectangle3d.vertices rectangle
--> [ Point3d.meters 0 1 2
--> , Point3d.meters 0 3 2
--> , Point3d.meters 0 3 4
--> , Point3d.meters 0 1 4
--> ]Construct a rectangle centered on the axes of the given sketch plane, with the given overall dimensions.
Get the overall dimensions (width and height) of a rectangle.
Get the central axes of a rectangle as a SketchPlane3d. The origin point
of the sketch plane will be the center point of the rectangle.
Get the X axis of a rectangle.
Get the Y axis of a rectangle.
Get the center point of a rectangle.
Get the area of a rectangle.
Get the vertices of a rectangle as a list. The vertices will be returned
in counterclockwise order with respect to the SketchPlane3d defining the
rectangle's axes.
Get the edges of a rectangle as a list. The edges will be returned
in counterclockwise order with respect to the SketchPlane3d defining the
rectangle's axes.
Get the minimal bounding box containing a given rectangle.
Interpolate within a rectangle based on coordinates which range from 0 to 1. For example, the four vertices of a given rectangle are
[ Rectangle3d.interpolate rectangle 0 0
, Rectangle3d.interpolate rectangle 1 0
, Rectangle3d.interpolate rectangle 1 1
, Rectangle3d.interpolate rectangle 0 1
]and its center point is
Rectangle3d.interpolate rectangle 0.5 0.5These transformations generally behave just like the ones in the Point3d
module.
Scale a rectangle about a given point by a given scale. Note that scaling by a negative value will flip the directions of the rectangle's axes.
Rotate a rectangle around a given axis by a given angle.
Translate a rectangle by a given displacement.
Translate a rectangle in a given direction by a given distance.
Mirror a rectangle across a given plane.
Convert a rectangle from one units type to another, by providing a conversion factor given as a rate of change of destination units with respect to source units.
Convert a rectangle from one units type to another, by providing an 'inverse' conversion factor given as a rate of change of source units with respect to destination units.
Take a rectangle defined in global coordinates, and return it expressed in local coordinates relative to a given reference frame.
Take a rectangle considered to be defined in local coordinates relative to a given reference frame, and return that rectangle expressed in global coordinates.