construction.SketchPlane

construction.SketchPlane(
    origin=(0.0, 0.0, 0.0),
    normal=(0.0, 0.0, 1.0),
    x_axis=None,
)

A work plane the sketch entities live on.

Defines a coordinate frame: origin plus orthonormal in-plane axes (u, v) derived from normal and, optionally, an explicit x_axis. Profile coordinates (x, y) map to world space as origin + x·u + y·v.

Parameters

Name Type Description Default
origin Plane origin in world space (Vector parameter or 3D array). (0.0, 0.0, 0.0)
normal Plane normal (Vector parameter or 3D array); default +Z, i.e. the world XY plane. (0.0, 0.0, 1.0)
x_axis Optional in-plane “horizontal”. Its component along the normal is removed, so any direction not parallel to the normal will do. Omit it to keep the normal-only derivation. Orientation is a snapshot — unlike origin it is not a tracked parameter — which mirrors how the generators already capture rotation at generation time. None

Attributes

Name Description
reference What this plane was derived from — a Face, an SDF, or None.
x_axis The explicit in-plane horizontal, or None when derived from the normal.

Methods

Name Description
axis_angle Axis-angle form of :meth:rotation_matrix (for the Rotate transform).
describe Serialize the plane’s frame for the viewer.
frame Return the (u, v, n) orthonormal frame as arrays.
is_identity True when the plane is the world XY plane at the origin.
midplane The plane halfway between two faces.
offset A face or plane pushed along its own normal.
on The plane of a face, moving with the feature’s parameters.
rotation_matrix Rotation taking local (x, y, z) to world (u, v, n), columns [u v n].
tangent The tangent plane of an SDF at the surface point nearest near.
to_world Map plane coordinates (…, 2) to world coordinates (…, 3).

axis_angle

construction.SketchPlane.axis_angle()

Axis-angle form of :meth:rotation_matrix (for the Rotate transform).

Returns

Name Type Description
tuple[Array, float | Array] The pair (axis, angle). angle is a Python float whenever the plane’s orientation is concrete — which is what lets :func:cadjoint.construction.extrude._place_on_plane drop an identity rotation entirely — and a traced array otherwise.

describe

construction.SketchPlane.describe()

Serialize the plane’s frame for the viewer.

frame

construction.SketchPlane.frame()

Return the (u, v, n) orthonormal frame as arrays.

is_identity

construction.SketchPlane.is_identity()

True when the plane is the world XY plane at the origin.

A plane whose origin or orientation is traced answers False: it cannot be proved identical to the world frame, and the placement transforms it then keeps are the identity anyway.

midplane

construction.SketchPlane.midplane(face_a, face_b)

The plane halfway between two faces.

Parameters

Name Type Description Default
face_a The first face (or plane). required
face_b The second face (or plane). required

Returns

Name Type Description
SketchPlane A plane at the midpoint of the two origins, normal to the average of the two normals. A face pair usually points at each other, so the second normal is flipped into agreement with the first before averaging; that keeps the result well defined for the parallel, antiparallel and general cases alike.

offset

construction.SketchPlane.offset(reference, distance)

A face or plane pushed along its own normal.

Parameters

Name Type Description Default
reference A :class:~cadjoint.construction.faces.Face or another :class:SketchPlane. required
distance How far to move along the normal. May be a Scalar parameter, in which case the offset is a design variable like any other. required

Returns

Name Type Description
SketchPlane The offset plane, keeping the reference’s orientation.

on

construction.SketchPlane.on(face, x_axis=None, flip=False)

The plane of a face, moving with the feature’s parameters.

Parameters

Name Type Description Default
face A :class:~cadjoint.construction.faces.Face — solid.cap("+"), solid.side(2), block.face("+x"). required
x_axis Override the sketch’s in-plane horizontal; defaults to the face’s own x axis (the profile’s u for a cap, the swept edge direction for a side wall). None
flip bool Face the plane the other way, keeping the same origin. False

Returns

Name Type Description
SketchPlane A plane whose origin is an expression in the parent feature’s parameters, so it follows the parent and carries its gradient.

Example

body = extrude(profile, depth=fin_depth)
boss = PolygonProfile(SQUARE, plane=SketchPlane.on(body.cap("+")))

rotation_matrix

construction.SketchPlane.rotation_matrix()

Rotation taking local (x, y, z) to world (u, v, n), columns [u v n].

tangent

construction.SketchPlane.tangent(
    solid,
    near,
    x_axis=None,
    *,
    max_step=1.0,
    steps=8,
    normal_step=0.001,
)

The tangent plane of an SDF at the surface point nearest near.

This is the reference for everything with no analytic face: blends, fillets, the curved wall of a revolve. near is Newton-projected onto the zero set with :func:cadjoint.fem.motion.project_points, and the plane’s normal is read off the field by a central difference across the surface — both differentiable, so the plane tracks the scene’s parameters rather than a snapshot of them. The difference is used in place of jax.grad because the surface is exactly where a CSG field changes branch; see :func:_surface_normal.

Parameters

Name Type Description Default
solid Any callable scalar field on (3,) points — an SDF instance is one. required
near A world point at or near the surface; a raymarch hit is the intended source. required
x_axis Override the in-plane horizontal; defaults to the world axis most nearly inside the tangent plane. None
max_step float Cap on how far the projection may move near. 1.0
steps int Newton iterations. 8
normal_step float Half-width of the central difference that reads the normal. Raise it on a field that is noisy at the surface, lower it where two faces meet within a thousandth. 0.001

Returns

Name Type Description
The tangent plane at the projected point.

to_world

construction.SketchPlane.to_world(xy)

Map plane coordinates (…, 2) to world coordinates (…, 3).