Skip to main content

Transform

Struct Transform 

Source
pub struct Transform {
    pub basis: [[f64; 3]; 3],
    pub origin: [f64; 3],
}
Expand description

An affine transform: a 3x3 linear part plus a translation.

Column-major: basis[i] is the image of basis vector i.

Fields§

§basis: [[f64; 3]; 3]

Images of the X, Y, Z basis vectors.

§origin: [f64; 3]

Translation applied after the linear part.

Implementations§

Source§

impl Transform

Source

pub const fn identity() -> Self

The identity transform.

Source

pub const fn translation(origin: [f64; 3]) -> Self

A pure translation.

Source

pub fn from_axes( origin: [f64; 3], axis: Option<[f64; 3]>, ref_direction: Option<[f64; 3]>, ) -> Option<Self>

Build from an origin and axis directions, Gram-Schmidt orthonormalized.

IFC gives Axis (local Z) and RefDirection (approximate local X) and explicitly allows them to be non-perpendicular: the spec derives X by projecting RefDirection onto the plane normal to Axis. Skipping that projection produces a sheared transform that looks almost right, which is worse than looking obviously wrong.

Returns None if the axes are degenerate (zero-length or parallel).

This is the schema’s IfcBuildAxes; the two derived axes come from IfcFirstProjAxis and IfcSecondProjAxis, marked inline below.

Source

pub fn from_axes_or_identity( origin: [f64; 3], axis: Option<[f64; 3]>, ref_direction: Option<[f64; 3]>, ) -> Self

Self::from_axes, falling back to the identity transform when the axes are absent or degenerate.

IFC’s Axis/RefDirection are both optional and, per spec, default to the standard basis when omitted — the common case, so most call sites that use from_axes immediately follow it with .unwrap_or_else(Transform::identity). This collapses that boilerplate. Reach for from_axes directly when a degenerate axis pair should be a reportable error instead of a silent identity.

Source

pub fn determinant(&self) -> f64

The determinant of the linear part: the signed volume scale.

Negative when the transform mirrors (reverses handedness), positive when it preserves it; its magnitude is the volume scale factor. Zero or non-finite only for a degenerate basis, which an IFC placement or a cartesian transformation operator cannot state validly (Scale is positive and the axes are independent).

Source

pub fn apply(&self, p: [f64; 3]) -> [f64; 3]

Apply this transform to a point.

Source

pub fn apply_direction(&self, v: [f64; 3]) -> [f64; 3]

Apply the linear part only, without translating.

Correct for vectors and tangents. Surface normals under non-uniform scale must use apply_unit_normal instead.

Source

pub fn to_geom_frame(self, entity: EntityId) -> GeometryResult<Frame3>

Convert to a neutral orthonormal frame at the IFC boundary.

axiolid_core::Frame3 is structurally public and cannot enforce unit, orthogonal, right-handed axes itself. This method is therefore the one executable IFC-to-Axiolid frame contract. It rejects non-finite origins, scaled or sheared axes, and mirrored frames before neutral construction. IFC placements reach this method after Axis/RefDirection have been normalized and Gram-Schmidt orthogonalized; mapped-item scale stays on an Instance transform and must never leak into a surface frame.

Source

pub fn to_geom(self) -> Transform3

Convert to the format-neutral geometry transform at the IFC boundary.

Source

pub fn compose(&self, inner: &Transform) -> Transform

Compose: self applied after inner.

This is the operation a placement chain folds with. Order matters and getting it backwards places every child relative to the wrong parent, so the convention is stated here once: parent.compose(&child) yields the child’s world transform.

Source

pub fn scaled(&self, factor: f64) -> Transform

Scale the linear part uniformly, e.g. for a transformation operator.

Source

pub fn scaled_nonuniform(&self, factors: [f64; 3]) -> Transform

Scale each axis independently, for the non-uniform operator.

Source

pub fn to_metres(self, units: &UnitScale) -> Transform

Convert the translation to metres, leaving the basis dimensionless.

IFC coordinates carry the file’s length unit; direction ratios and scale factors do not. Scaling the basis as well would compound the unit into every rotation and silently resize geometry, so only the origin is converted. Apply this exactly once, at the boundary where a source frame becomes project space.

Source

pub fn is_identity(&self, tolerance: f64) -> bool

Is this within tolerance of the identity?

Trait Implementations§

Source§

impl Clone for Transform

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Transform

Source§

impl Debug for Transform

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Transform

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Transform

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Transform

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.