Enum ExprKind

Source
pub enum ExprKind {
Show 31 variants Entity { id: EntityIndex, }, LineLineIntersection { k: VarIndex, l: VarIndex, }, AveragePoint { items: Vec<VarIndex>, }, CircleCenter { circle: VarIndex, }, ComplexToPoint { number: VarIndex, }, Sum { plus: Vec<VarIndex>, minus: Vec<VarIndex>, }, Product { times: Vec<VarIndex>, by: Vec<VarIndex>, }, Const { value: ProcNum, }, Exponentiation { value: VarIndex, exponent: CompExponent, }, PointPointDistance { p: VarIndex, q: VarIndex, }, PointLineDistance { point: VarIndex, line: VarIndex, }, ThreePointAngle { p: VarIndex, q: VarIndex, r: VarIndex, }, ThreePointAngleDir { p: VarIndex, q: VarIndex, r: VarIndex, }, TwoLineAngle { k: VarIndex, l: VarIndex, }, PointX { point: VarIndex, }, PointY { point: VarIndex, }, PointToComplex { point: VarIndex, }, Real { number: VarIndex, }, Imaginary { number: VarIndex, }, Log { number: VarIndex, }, Exp { number: VarIndex, }, Sin { angle: VarIndex, }, Cos { angle: VarIndex, }, Atan2 { y: VarIndex, x: VarIndex, }, DirectionVector { line: VarIndex, }, PointPoint { p: VarIndex, q: VarIndex, }, AngleBisector { p: VarIndex, q: VarIndex, r: VarIndex, }, ParallelThrough { point: VarIndex, line: VarIndex, }, PerpendicularThrough { point: VarIndex, line: VarIndex, }, PointVector { point: VarIndex, vector: VarIndex, }, ConstructCircle { center: VarIndex, radius: VarIndex, },
}
Expand description

A mathematical expression with a flattened memory model.

Variants§

§

Entity

An entity referece.

Fields

§

LineLineIntersection

An intersection of two lines: k and l

§

AveragePoint

The arithmetic mean of given point expressions

Fields

§items: Vec<VarIndex>
§

CircleCenter

Center of a circle.

Fields

§circle: VarIndex
§

ComplexToPoint

Convert a complex number to a point (no-op)

Fields

§number: VarIndex
§

Sum

Sum of numbers.

A normalized sum must be sorted and must not contain other sums or negations. An aggregated constant, if any, must be at the end.

Fields

§plus: Vec<VarIndex>

Items to add.

§minus: Vec<VarIndex>

Items to subtract.

§

Product

Product of numbers.

A normalized product must be sorted and must not contain other products. An aggregated constant, if any, must be at the end.

Fields

§times: Vec<VarIndex>

Items to multiply by.

§by: Vec<VarIndex>

Items to divide by.

§

Const

A constant.

Fields

§value: ProcNum
§

Exponentiation

Raising a value to a power.

Fields

§value: VarIndex
§exponent: CompExponent
§

PointPointDistance

A distance between two points.

§

PointLineDistance

A distance of a point from a line.

Fields

§point: VarIndex
§

ThreePointAngle

An angle defined by three points (arm, origin, arm)

Fields

§p: VarIndex

Angle’s one arm.

§q: VarIndex

Angle’s origin

§r: VarIndex

Angle’s other arm

§

ThreePointAngleDir

A directed angle defined by three points (arm, origin, arm)

Fields

§p: VarIndex

Angle’s first arm.

§q: VarIndex

Angle’s origin.

§r: VarIndex

Angle’s second arm.

§

TwoLineAngle

The angle described by two lines.

§

PointX

The real part of a point.

Fields

§point: VarIndex
§

PointY

The imaginary part of a point.

Fields

§point: VarIndex
§

PointToComplex

Convert a point to a complex number (no-op)

Fields

§point: VarIndex
§

Real

Real part of a number

Fields

§number: VarIndex
§

Imaginary

Imaginary part of a number

Fields

§number: VarIndex
§

Log

Natural logarithm

Fields

§number: VarIndex
§

Exp

Exponential function (e^this)

Fields

§number: VarIndex
§

Sin

Sine of an angle

Fields

§angle: VarIndex
§

Cos

Cosine of an angle

Fields

§angle: VarIndex
§

Atan2

Arctan2 function

§

DirectionVector

Line’s direction vector

Fields

§

PointPoint

A line through two points.

§

AngleBisector

The angle bisector line.

§

ParallelThrough

A line parallel to another line going through a point

Fields

§point: VarIndex
§

PerpendicularThrough

A line perpendicular to another line going through a point

Fields

§point: VarIndex
§

PointVector

A line made from a point and a direction vector

Fields

§point: VarIndex
§vector: VarIndex
§

ConstructCircle

A circle constructed from its center and radius.

Fields

§center: VarIndex
§radius: VarIndex

Implementations§

Source§

impl ExprKind

Source

pub fn variant_id(&self) -> usize

Get the id of a variant. Used for comparison

Source

pub fn compare(&self, other: &Self, math: &Math) -> Ordering

Compare two expressions.

Source

pub fn get_type<M>( &self, expressions: &[Expr<M>], entities: &[Entity<M>], ) -> ExprType

Get the expression’s type.

Trait Implementations§

Source§

impl Clone for ExprKind

Source§

fn clone(&self) -> ExprKind

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ExprKind

Source§

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

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

impl DeepClone for ExprKind

Source§

fn deep_clone(&self, arg0: &mut Math) -> Self

Perform a deep clone.
Source§

impl Default for ExprKind

Source§

fn default() -> Self

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

impl From<ExprKind> for ExpressionKind

Source§

fn from(value: ExprKind) -> Self

Converts to this type from the input type.
Source§

impl FromUnrolled<Circle> for ExprKind

Source§

fn load(expr: &Unrolled<UnrolledCircle>, math: &mut Expand) -> Self

Load the unroll expression
Source§

impl FromUnrolled<Line> for ExprKind

Source§

fn load(expr: &Unrolled<UnrolledLine>, math: &mut Expand) -> Self

Load the unroll expression
Source§

impl FromUnrolled<Number> for ExprKind

Source§

fn load(expr: &Unrolled<Number>, math: &mut Expand) -> Self

Load the unroll expression
Source§

impl FromUnrolled<Point> for ExprKind

Source§

fn load(expr: &Unrolled<UnrolledPoint>, math: &mut Expand) -> Self

Load the unroll expression
Source§

impl Hash for ExprKind

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for ExprKind

Source§

fn cmp(&self, other: &ExprKind) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for ExprKind

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for ExprKind

Source§

fn partial_cmp(&self, other: &ExprKind) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Reconstruct for ExprKind

Source§

fn reconstruct(self, arg0: &mut ReconstructCtx<'_>) -> Self

Reconstruct the value.
Source§

impl Reindex for ExprKind

Source§

fn reindex(&mut self, arg0: &IndexMap)

Reindex the expression/rule according to the given map.
Source§

impl Serialize for ExprKind

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 Eq for ExprKind

Source§

impl StructuralPartialEq for ExprKind

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> CloneWithNode for T
where T: Clone,

Source§

fn clone_with_node(&mut self) -> T

Clone self and take its node.
Source§

fn clone_without_node(&self) -> T

Clone self without taking its node.
Source§

impl<T> Convert for T

Source§

fn convert<U>(self, context: &CompileContext) -> Expr<U>
where U: ConvertFrom<T>,

Convert self into a specific type. Read more
Source§

fn can_convert<U>(&self) -> bool
where U: ConvertFrom<T>,

Check if self can be converted into a specific type. 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> 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.