Various functions for creating and working with SketchPlane3d values.
Sketch planes are defined by an origin point and X and Y basis directions in 3D,
which define a 2D coordinate system (the X and Y basis directions are always
perpendicular). A sketch plane can therefore be used to convert between 2D and
3D coordinates, such as taking 2D lines and placing them on a 3D plane, or
projecting a 3D point into a 2D sketch.
Sketch planes can be constructed explicitly by passing a record with
originPoint, xDirection and yDirection fields to the SketchPlane3d
constructor, for example
sketchPlane =
SketchPlane3d
{ originPoint = Point3d ( 2, 1, 3 )
, xDirection = Direction3d.y
, yDirection = Direction3d.flip Direction3d.z
}If you construct a SketchPlane3d this way, you must ensure that the X and Y
basis directions are perpendicular to each other.
These predefined sketch planes all have the global origin point as their origin point, and use the two indicated global axes as their X and Y axes. For example,
SketchPlane3d.yz ==
SketchPlane3d
{ originPoint = Point3d.origin
, xDirection = Direction3d.y
, yDirection = Direction3d.z
}A sketch plane formed from the global Y and X axes.
A sketch plane formed from the global Y and Z axes.
A sketch plane formed from the global Z and Y axes.
A sketch plane formed from the global Z and X axes.
A sketch plane formed from the global X and Z axes.
Get the origin point of a sketch plane.
SketchPlane3d.originPoint SketchPlane3d.xy ==
Point3d.originGet the X direction of a sketch plane (the direction of the sketch plane's X axis).
SketchPlane3d.xDirection SketchPlane3d.zx ==
Direction3d.zGet the Y direction of a sketch plane (the direction of the sketch plane's Y axis).
SketchPlane3d.yDirection SketchPlane3d.zx ==
Direction3d.xGet the normal direction to a sketch plane. This is equal to the cross product of the sketch plane's X and Y directions.
SketchPlane3d.normalDirection SketchPlane3d.xy ==
Direction3d.z
SketchPlane3d.normalDirection SketchPlane3d.xz ==
Direction3d.flip Direction3d.yGet the X axis of a sketch plane. A 2D X coordinate within the sketch plane corresponds to a distance along this axis in 3D.
SketchPlane3d.xAxis SketchPlane3d.zx ==
Axis3d.zGet the Y axis of a sketch plane. A 2D Y coordinate within the sketch plane corresponds to a distance along this axis in 3D.
SketchPlane3d.yAxis SketchPlane3d.zx ==
Axis3d.xGet the normal axis to a sketch plane (the axis formed from the sketch plane's origin point and normal direction).
SketchPlane3d.normalAxis SketchPlane3d.xy ==
Axis3d.z
SketchPlane3d.normalAxis SketchPlane3d.xz ==
Axis3d.flip Axis3d.yConver a SketchPlane3d to a Plane3d with the same origin point and
normal direction.
SketchPlane3d.plane SketchPlane3d.xy ==
Plane3d.xy
SketchPlane3d.plane SketchPlane3d.yx ==
Plane3d.flip Plane3d.xyFlip the X direction of a sketch plane, leaving its Y direction and origin point unchanged.
SketchPlane3d.flipX SketchPlane3d.yz ==
SketchPlane3d
{ originPoint = Point3d.origin
, xDirection = Direction3d.flip Direction3d.y
, yDirection = Direction3d.z
}Flip the Y direction of a sketch plane, leaving its X direction and origin point unchanged.
SketchPlane3d.flipY SketchPlane3d.yz ==
SketchPlane3d
{ originPoint = Point3d.origin
, xDirection = Direction3d.y
, yDirection = Direction3d.flip Direction3d.z
}Set the origin point of the given sketch plane to the given point, leaving its X and Y directions unchanged.
SketchPlane3d.moveTo (Point3d ( 2, 1, 3 )) SketchPlane3d.yz ==
SketchPlane3d
{ originPoint = Point3d ( 2, 1, 3 )
, xDirection = Direction3d.y
, yDirection = Direction3d.z
}Rotate a sketch plane around an axis by a given angle (in radians). The sketch plane's origin point and X and Y directions will all be rotated around the given axis.
SketchPlane3d.rotateAround Axis3d.x (degrees 90) SketchPlane3d.xy ==
SketchPlane3d.xzRotate a sketch plane around one of its own axes by a given angle (in radians).
The first argument is a function that returns the axis to rotate around, given
the current sketch plane. The majority of the time this will be either
SketchPlane3d.xAxis or SketchPlane3d.yAxis.
This function is convenient when constructing sketch planes via a series of transformations. For example,
sketchPlane =
SketchPlane3d.xy
|> SketchPlane3d.translateBy (Vector3d ( 1, 0, 0 ))
|> SketchPlane3d.rotateAroundOwn SketchPlane3d.yAxis (degrees -45)
sketchPlane ==
SketchPlane3d
{ originPoint = Point3d ( 1, 0, 0 )
, xDirection = Direction3d ( 0.7071, 0, 0.7071 )
, yDirection = Direction3d.y
}Note that since the rotation was around the sketch plane's own Y axis (which passes through the sketch plane's origin point) instead of the global Y axis, the origin point itself was not affected by the rotation.
Translate a sketch plane by a given displacement.
displacement =
Vector3d ( 2, 1, 3 )
SketchPlane3d.translateBy displacement SketchPlane3d.xy ==
SketchPlane3d
{ originPoint = Point3d ( 2, 1, 3 )
, xDirection = Direction3d.x
, yDirection = Direction3d.y
}Translate a sketch plane along one of its own axes by a given distance.
The first argument is a function that returns the axis to translate along, given
the current sketch plane. The majority of the time this will be either
SketchPlane3d.xAxis or SketchPlane3d.yAxis.
This function is convenient when constructing frames via a series of transformations. For example,
SketchPlane3d.xy
|> SketchPlane3d.rotateAround Axis3d.x (degrees 45)
|> SketchPlane3d.translateAlongOwn SketchPlane3d.yAxis 2means 'take the global XY sketch plane, rotate it around the global X axis by 45 degrees, then translate the result 2 units along its own (rotated) Y axis', resulting in
SketchPlane3d
{ originPoint = Point3d ( 0, 1.4142, 1.4142 )
, xDirection = Direction3d.x
, yDirection = Direction3d ( 0, 0.7071, 0.7071 )
}Mirror a sketch plane across a plane.
sketchPlane =
SketchPlane3d
{ originPoint = Point2d ( 2, 1, 3 )
, xDirection = Direction3d.y
, yDirection = Direction3d.z
}
SketchPlane3d.mirrorAcross Plane3d.xy sketchPlane ==
SketchPlane3d
{ originPoint = Point2d ( 2, 1, -3 )
, xDirection = Direction3d.y
, yDirection = Direction3d.flip Direction3d.z
}Take a sketch plane defined in global coordinates, and return it expressed in local coordinates relative to a given reference frame.
Take a sketch plane defined in local coordinates relative to a given reference frame, and return that sketch plane expressed in global coordinates.
A sketch plane formed from the global X and Y axes.