Declare std::offsetPlane in KCL (#6344)
* Declare std::offsetPlane in KCL Signed-off-by: Nick Cameron <nrc@ncameron.org> * Use two axes to define planes in KCL Signed-off-by: Nick Cameron <nrc@ncameron.org> --------- Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -12,21 +12,18 @@ export XY = {
|
||||
origin = { x = 0, y = 0, z = 0 },
|
||||
xAxis = { x = 1, y = 0, z = 0 },
|
||||
yAxis = { x = 0, y = 1, z = 0 },
|
||||
zAxis = { x = 0, y = 0, z = 1 },
|
||||
}: Plane
|
||||
|
||||
export XZ = {
|
||||
origin = { x = 0, y = 0, z = 0 },
|
||||
xAxis = { x = 1, y = 0, z = 0 },
|
||||
yAxis = { x = 0, y = 0, z = 1 },
|
||||
zAxis = { x = 0, y = -1, z = 0 },
|
||||
}: Plane
|
||||
|
||||
export YZ = {
|
||||
origin = { x = 0, y = 0, z = 0 },
|
||||
xAxis = { x = 0, y = 1, z = 0 },
|
||||
yAxis = { x = 0, y = 0, z = 1 },
|
||||
zAxis = { x = 1, y = 0, z = 0 },
|
||||
}: Plane
|
||||
|
||||
export X = {
|
||||
@ -449,3 +446,93 @@ export fn toRadians(@num: number(rad)): number(rad) {
|
||||
export fn toDegrees(@num: number(deg)): number(deg) {
|
||||
return num
|
||||
}
|
||||
|
||||
/// Offset a plane by a distance along its normal.
|
||||
///
|
||||
/// For example, if you offset the `XZ` plane by 10, the new plane will be parallel to the `XZ`
|
||||
/// plane and 10 units away from it.
|
||||
///
|
||||
/// ```
|
||||
/// // Loft a square and a circle on the `XY` plane using offset.
|
||||
/// squareSketch = startSketchOn(XY)
|
||||
/// |> startProfileAt([-100, 200], %)
|
||||
/// |> line(end = [200, 0])
|
||||
/// |> line(end = [0, -200])
|
||||
/// |> line(end = [-200, 0])
|
||||
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
/// |> close()
|
||||
///
|
||||
/// circleSketch = startSketchOn(offsetPlane(XY, offset = 150))
|
||||
/// |> circle( center = [0, 100], radius = 50 )
|
||||
///
|
||||
/// loft([squareSketch, circleSketch])
|
||||
/// ```
|
||||
///
|
||||
/// ```
|
||||
/// // Loft a square and a circle on the `XZ` plane using offset.
|
||||
/// squareSketch = startSketchOn(XZ)
|
||||
/// |> startProfileAt([-100, 200], %)
|
||||
/// |> line(end = [200, 0])
|
||||
/// |> line(end = [0, -200])
|
||||
/// |> line(end = [-200, 0])
|
||||
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
/// |> close()
|
||||
///
|
||||
/// circleSketch = startSketchOn(offsetPlane(XZ, offset = 150))
|
||||
/// |> circle( center = [0, 100], radius = 50 )
|
||||
///
|
||||
/// loft([squareSketch, circleSketch])
|
||||
/// ```
|
||||
///
|
||||
/// ```
|
||||
/// // Loft a square and a circle on the `YZ` plane using offset.
|
||||
/// squareSketch = startSketchOn(YZ)
|
||||
/// |> startProfileAt([-100, 200], %)
|
||||
/// |> line(end = [200, 0])
|
||||
/// |> line(end = [0, -200])
|
||||
/// |> line(end = [-200, 0])
|
||||
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
/// |> close()
|
||||
///
|
||||
/// circleSketch = startSketchOn(offsetPlane(YZ, offset = 150))
|
||||
/// |> circle( center = [0, 100], radius = 50 )
|
||||
///
|
||||
/// loft([squareSketch, circleSketch])
|
||||
/// ```
|
||||
///
|
||||
/// ```
|
||||
/// // Loft a square and a circle on the `-XZ` plane using offset.
|
||||
/// squareSketch = startSketchOn(-XZ)
|
||||
/// |> startProfileAt([-100, 200], %)
|
||||
/// |> line(end = [200, 0])
|
||||
/// |> line(end = [0, -200])
|
||||
/// |> line(end = [-200, 0])
|
||||
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
/// |> close()
|
||||
///
|
||||
/// circleSketch = startSketchOn(offsetPlane(-XZ, offset = 150))
|
||||
/// |> circle(center = [0, 100], radius = 50)
|
||||
///
|
||||
/// loft([squareSketch, circleSketch])
|
||||
/// ```
|
||||
///
|
||||
/// ```
|
||||
/// // A circle on the XY plane
|
||||
/// startSketchOn(XY)
|
||||
/// |> startProfileAt([0, 0], %)
|
||||
/// |> circle( radius = 10, center = [0, 0] )
|
||||
///
|
||||
/// // Triangle on the plane 4 units above
|
||||
/// startSketchOn(offsetPlane(XY, offset = 4))
|
||||
/// |> startProfileAt([0, 0], %)
|
||||
/// |> line(end = [10, 0])
|
||||
/// |> line(end = [0, 10])
|
||||
/// |> close()
|
||||
/// ```
|
||||
@(impl = std_rust)
|
||||
export fn offsetPlane(
|
||||
/// The plane (e.g. `XY`) which this new plane is created from.
|
||||
@plane: Plane,
|
||||
/// Distance from the standard plane this new plane will be created at.
|
||||
offset: number(Length),
|
||||
): Plane {}
|
||||
|
Reference in New Issue
Block a user