Skip to main content

Constraint

Enum Constraint 

Source
pub enum Constraint {
Show 26 variants Coincident { a: PointId, b: PointId, }, PointOnCurve { point: PointId, curve: CurveId, }, Horizontal { line: CurveId, }, Vertical { line: CurveId, }, Parallel { a: CurveId, b: CurveId, }, Perpendicular { a: CurveId, b: CurveId, }, Collinear { a: CurveId, b: CurveId, }, Tangent { a: CurveId, b: CurveId, }, Equal { a: CurveId, b: CurveId, }, Concentric { a: CurveId, b: CurveId, }, Center { point: PointId, curve: CurveId, }, Midpoint { point: PointId, curve: CurveId, }, Symmetric { a: PointId, b: PointId, line: CurveId, }, Fix { point: PointId, x: Scalar, y: Scalar, }, Distance { a: PointId, b: PointId, value: Scalar, }, DistanceX { a: PointId, b: PointId, value: Scalar, }, DistanceY { a: PointId, b: PointId, value: Scalar, }, PointLineDistance { point: PointId, line: CurveId, value: Scalar, }, Length { curve: CurveId, value: Scalar, }, Radius { curve: CurveId, value: Scalar, }, Diameter { curve: CurveId, value: Scalar, }, Angle { a: CurveId, b: CurveId, value: Scalar, }, Moved { a: PointId, b: PointId, by: CurveId, }, EqualSweep { a: CurveId, b: CurveId, }, Offset { a: CurveId, b: CurveId, value: Scalar, }, OffsetAt { a: CurveId, at: Scalar, b: CurveId, on: Scalar, by: CurveId, across: bool, },
}
Expand description

The typical CAD sketch constraints. Distances and lengths are in sketch units, angles in radians.

Variants§

§

Coincident

a and b are the same point.

Fields

§

PointOnCurve

point lies on curve (a line’s infinite extension, an arc’s full circle, or a circle).

Fields

§point: PointId
§curve: CurveId
§

Horizontal

Fields

§line: CurveId
§

Vertical

Fields

§line: CurveId
§

Parallel

Fields

§

Perpendicular

Fields

§

Collinear

Two lines on one infinite line.

Fields

§

Tangent

Two curves meet tangentially: at a shared endpoint if they have one (lines, arcs and splines), else a line touching a circle/arc, or two circles/arcs touching each other.

Fields

§

Equal

Equal length (two lines) or equal radius (two circles/arcs).

Fields

§

Concentric

Two circles/arcs share a center.

Fields

§

Center

point is the center of a circle or arc.

Fields

§point: PointId
§curve: CurveId
§

Midpoint

point is the midpoint of a line or arc.

Fields

§point: PointId
§curve: CurveId
§

Symmetric

a and b are mirror images across line.

Fields

§line: CurveId
§

Fix

point stays at (x, y).

Fields

§point: PointId
§

Distance

Fields

§value: Scalar
§

DistanceX

b.x - a.x = value.

Fields

§value: Scalar
§

DistanceY

b.y - a.y = value.

Fields

§value: Scalar
§

PointLineDistance

Fields

§point: PointId
§line: CurveId
§value: Scalar
§

Length

Length of a line or arc.

Fields

§curve: CurveId
§value: Scalar
§

Radius

Radius of a circle or arc.

Fields

§curve: CurveId
§value: Scalar
§

Diameter

Diameter of a circle or arc.

Fields

§curve: CurveId
§value: Scalar
§

Angle

The counter-clockwise angle from line a’s direction to line b’s.

Fields

§value: Scalar
§

Moved

b is a moved the way by carries its start onto its end: along a line, shifted by it; round an arc, turned about the arc’s center by its sweep. How a pattern’s copies follow what they copy (see crate::copies).

§

EqualSweep

Two arcs turn by the same angle: an arc whose ends are the images of another’s, under a motion or a reflection, is then its image.

Fields

§

Offset

b runs value from a: two parallel lines value apart, or two concentric circles/arcs whose radii differ by value (see crate::offset).

Fields

§value: Scalar
§

OffsetAt

The point on along the spline b lies the radius of the circle by from the point at along the spline a, along a’s normal there — or, across, only that far across it: anywhere on the line a’s offset runs along there. Each as a fraction of the spline’s domain. The offset of a spline is no spline: a spline fitted through such points is held to it (see crate::offset).

Implementations§

Source§

impl Constraint

Source

pub fn value(&self) -> Option<Scalar>

The dimension it holds, if it holds one — an angle in radians: what a dialog edits.

Source

pub fn set_value(&mut self, v: Scalar)

Gives its dimension the value v — an angle in radians; nothing for one without.

Source

pub fn points(&self) -> Vec<PointId>

The points this constraint refers to directly (curves aside).

Source

pub fn curves(&self) -> Vec<CurveId>

The curves this constraint refers to.

Trait Implementations§

Source§

impl Clone for Constraint

Source§

fn clone(&self) -> Constraint

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 Debug for Constraint

Source§

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

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

impl<'de> Deserialize<'de> for Constraint

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Constraint

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for Constraint

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Constraint

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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.