API Reference

Math Utils

class modelviewprojection.mathutils.Vector[source]

Bases: object

__add__(rhs: Self) Self[source]

Add together two Vectors, component-wise.

Parameters:

rhs (Vector) – The vector on the right hand side of the addition symbol

Returns:

The Vector that represents the additon of the two

input Vectors

Return type:

Vector

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2)
>>> b = Vector1D(x=5)
>>> a + b
Vector1D(x=7)
>>> from modelviewprojection.mathutils2d import Vector2D
>>> a = Vector2D(x=2, y=3)
>>> b = Vector2D(x=5, y=6)
>>> a + b
Vector2D(x=7, y=9)
>>> from modelviewprojection.mathutils3d import Vector3D
>>> a = Vector3D(x=2, y=3, z=1)
>>> b = Vector3D(x=5, y=6, z=10)
>>> a + b
Vector3D(x=7, y=9, z=11)
__mul__(scalar: float) Self[source]

Multiply the Vector by a scalar number, component-wise

Parameters:

rhs (Vector) – The scalar to be multiplied to the Vector’s component subtraction symbol

Returns:

The Vector that represents scalar times the amount of the input

Vector

Return type:

Vector

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2)
>>> a * 4
Vector1D(x=8)
>>> from modelviewprojection.mathutils2d import Vector2D
>>> a = Vector2D(x=2, y=3)
>>> a * 4
Vector2D(x=8, y=12)
>>> from modelviewprojection.mathutils3d import Vector3D
>>> a = Vector3D(x=2, y=3, z=5)
>>> a * 4
Vector3D(x=8, y=12, z=20)
__neg__() Self[source]

Let \(\vec{a}\) and constant \(-1\):

\[-1 * \vec{a}\]

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2.0)
>>> -a
Vector1D(x=-2.0)
__sub__(rhs: Self) Self[source]
\[\vec{a} + -\vec{b}\]

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2.0)
>>> b = Vector1D(x=5.0)
>>> a - b
Vector1D(x=-3.0)
__rmul__(scalar: float) Self[source]
isclose(other: Self) float[source]
component_wise_with_index(other: Self)[source]
dot(other: Self) float[source]
class modelviewprojection.mathutils.InvertibleFunction(func: Callable[[Vector], Vector], inverse: Callable[[Vector], Vector])[source]

Bases: object

Class that wraps a function and its inverse function. The function takes type T as it’s argument and it’s evaluation results in a value of type T.

func: Callable[[Vector], Vector]

The wrapped function

inverse: Callable[[Vector], Vector]

The inverse of the wrapped function

modelviewprojection.mathutils.inverse(f: InvertibleFunction) InvertibleFunction[source]

Get the inverse of the InvertibleFunction

Parameters:

f – InvertibleFunction: A function with it’s associated inverse function.

Returns:

The Inverse of the function

function.

Return type:

InvertibleFunction

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils import InvertibleFunction
>>> from modelviewprojection.mathutils import inverse
>>> def f(x):
...     return 2 + x
...
>>> def f_inv(x):
...     return x - 2
...
>>> foo = InvertibleFunction(func=f, inverse=f_inv)
>>> foo 
InvertibleFunction(func=<function f at 0x...>, inverse=<function f_inv at 0x...>)
>>> foo(5)
7
>>> inverse(foo) 
InvertibleFunction(func=<function f_inv at 0x...>, inverse=<function f at 0x...>)
>>> inverse(foo)(foo(5))
5
modelviewprojection.mathutils.compose(functions: list[InvertibleFunction]) InvertibleFunction[source]

Compose a sequence of functions.

If two functions are passed as arguments, named \(f\) and \(g\):

\((f \circ g)(x) = f(g(x))\).

If \(n\) functions are passed as arguments, \(f_1...f_n\):

\((f_1 \circ (f_2 \circ (... f_n )(x) = f_1(f_2...(f_n(x))\).

Parameters:

functions (list[InvertibleFunction]) – Variable number of InvertibleFunctions to compose. At least on value must be provided.

Returns:

One function that is the aggregate function of the argument

functions composed.

Return type:

Vector

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils import compose
>>> compose([lambda x: 5])(1)
5
>>> compose([lambda x: 2*x])(1)
2
>>> compose([lambda x: x+4, lambda x: 2*x])(1)
6
>>> compose([lambda x: x+ 10, lambda x: x+4, lambda x: 2*x])(1)
16
modelviewprojection.mathutils.compose_intermediate_fns(functions: list[InvertibleFunction], relative_basis: bool = False) Iterable[InvertibleFunction][source]

Like compose, but returns a list of all of the partial compositions

Example

>>> from modelviewprojection.mathutils import compose_intermediate_fns, InvertibleFunction, uniform_scale, translate
>>> from modelviewprojection.mathutils1d import Vector1D
>>> from pytest import approx
>>> m = 5.0
>>> b = 2.0
>>> # natural basis
>>> fns: list[InvertibleFunction] = compose_intermediate_fns(
...      [translate(Vector1D(b)), uniform_scale(m)]
... )
>>> len(fns)
2
>>> fns[0](Vector1D(1))
Vector1D(x=5.0)
>>> fns[1](Vector1D(1))
Vector1D(x=7.0)
>>> # relative basis
>>> fns: list[InvertibleFunction] = compose_intermediate_fns(
...     [translate(Vector1D(b)), uniform_scale(m)], relative_basis=True
... )
>>> len(fns)
2
>>> fns[0](Vector1D(1))
Vector1D(x=3.0)
>>> fns[1](Vector1D(1))
Vector1D(x=7.0)
modelviewprojection.mathutils.compose_intermediate_fns_and_fn(functions: list[InvertibleFunction], relative_basis: bool = False) list[tuple[InvertibleFunction, InvertibleFunction]][source]

Like compose, but returns a list of all of the partial compositions

Example

>>> from modelviewprojection.mathutils import compose_intermediate_fns_and_fn, InvertibleFunction, uniform_scale, translate
>>> from modelviewprojection.mathutils1d import Vector1D
>>> from pytest import approx
>>> m = 5.0
>>> b = 2.0
>>> # natural basis
>>> for aggregate_fn, current_fn in compose_intermediate_fns_and_fn(
...      [translate(Vector1D(b)), uniform_scale(m)]):
...      print("agg " + str(aggregate_fn(Vector1D(1.0))))
...      print("current " + str(current_fn(Vector1D(1.0))))
...
agg Vector1D(x=5.0)
current Vector1D(x=5.0)
agg Vector1D(x=7.0)
current Vector1D(x=3.0)
>>> # relative basis
>>> for aggregate_fn, current_fn in compose_intermediate_fns_and_fn(
...      [translate(Vector1D(b)), uniform_scale(m)], relative_basis=True):
...      print("agg " + str(aggregate_fn(Vector1D(1.0))))
...      print("current " + str(current_fn(Vector1D(1.0))))
...
agg Vector1D(x=3.0)
current Vector1D(x=3.0)
agg Vector1D(x=7.0)
current Vector1D(x=5.0)
modelviewprojection.mathutils.translate(b: Vector) InvertibleFunction[source]
modelviewprojection.mathutils.uniform_scale(m: float) InvertibleFunction[source]

Math Utils 1D

class modelviewprojection.mathutils1d.Vector1D(x: float)[source]

Bases: Vector

x: float

The value of the 1D mu.Vector

modelviewprojection.mathutils1d.translate(b: Vector) InvertibleFunction[source]
modelviewprojection.mathutils1d.uniform_scale(m: float) InvertibleFunction[source]
class modelviewprojection.mathutils1d.InvertibleFunction(func: Callable[[Vector], Vector], inverse: Callable[[Vector], Vector])[source]

Bases: object

Class that wraps a function and its inverse function. The function takes type T as it’s argument and it’s evaluation results in a value of type T.

func: Callable[[Vector], Vector]

The wrapped function

inverse: Callable[[Vector], Vector]

The inverse of the wrapped function

modelviewprojection.mathutils1d.inverse(f: InvertibleFunction) InvertibleFunction[source]

Get the inverse of the InvertibleFunction

Parameters:

f – InvertibleFunction: A function with it’s associated inverse function.

Returns:

The Inverse of the function

function.

Return type:

InvertibleFunction

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils import InvertibleFunction
>>> from modelviewprojection.mathutils import inverse
>>> def f(x):
...     return 2 + x
...
>>> def f_inv(x):
...     return x - 2
...
>>> foo = InvertibleFunction(func=f, inverse=f_inv)
>>> foo 
InvertibleFunction(func=<function f at 0x...>, inverse=<function f_inv at 0x...>)
>>> foo(5)
7
>>> inverse(foo) 
InvertibleFunction(func=<function f_inv at 0x...>, inverse=<function f at 0x...>)
>>> inverse(foo)(foo(5))
5
modelviewprojection.mathutils1d.compose(functions: list[InvertibleFunction]) InvertibleFunction[source]

Compose a sequence of functions.

If two functions are passed as arguments, named \(f\) and \(g\):

\((f \circ g)(x) = f(g(x))\).

If \(n\) functions are passed as arguments, \(f_1...f_n\):

\((f_1 \circ (f_2 \circ (... f_n )(x) = f_1(f_2...(f_n(x))\).

Parameters:

functions (list[InvertibleFunction]) – Variable number of InvertibleFunctions to compose. At least on value must be provided.

Returns:

One function that is the aggregate function of the argument

functions composed.

Return type:

Vector

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils import compose
>>> compose([lambda x: 5])(1)
5
>>> compose([lambda x: 2*x])(1)
2
>>> compose([lambda x: x+4, lambda x: 2*x])(1)
6
>>> compose([lambda x: x+ 10, lambda x: x+4, lambda x: 2*x])(1)
16
class modelviewprojection.mathutils1d.Vector[source]

Bases: object

__add__(rhs: Self) Self[source]

Add together two Vectors, component-wise.

Parameters:

rhs (Vector) – The vector on the right hand side of the addition symbol

Returns:

The Vector that represents the additon of the two

input Vectors

Return type:

Vector

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2)
>>> b = Vector1D(x=5)
>>> a + b
Vector1D(x=7)
>>> from modelviewprojection.mathutils2d import Vector2D
>>> a = Vector2D(x=2, y=3)
>>> b = Vector2D(x=5, y=6)
>>> a + b
Vector2D(x=7, y=9)
>>> from modelviewprojection.mathutils3d import Vector3D
>>> a = Vector3D(x=2, y=3, z=1)
>>> b = Vector3D(x=5, y=6, z=10)
>>> a + b
Vector3D(x=7, y=9, z=11)
__mul__(scalar: float) Self[source]

Multiply the Vector by a scalar number, component-wise

Parameters:

rhs (Vector) – The scalar to be multiplied to the Vector’s component subtraction symbol

Returns:

The Vector that represents scalar times the amount of the input

Vector

Return type:

Vector

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2)
>>> a * 4
Vector1D(x=8)
>>> from modelviewprojection.mathutils2d import Vector2D
>>> a = Vector2D(x=2, y=3)
>>> a * 4
Vector2D(x=8, y=12)
>>> from modelviewprojection.mathutils3d import Vector3D
>>> a = Vector3D(x=2, y=3, z=5)
>>> a * 4
Vector3D(x=8, y=12, z=20)
__neg__() Self[source]

Let \(\vec{a}\) and constant \(-1\):

\[-1 * \vec{a}\]

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2.0)
>>> -a
Vector1D(x=-2.0)
__sub__(rhs: Self) Self[source]
\[\vec{a} + -\vec{b}\]

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2.0)
>>> b = Vector1D(x=5.0)
>>> a - b
Vector1D(x=-3.0)
__rmul__(scalar: float) Self[source]
isclose(other: Self) float[source]
component_wise_with_index(other: Self)[source]
dot(other: Self) float[source]

Math Utils 2D

class modelviewprojection.mathutils2d.Vector2D(x: float, y: float)[source]

Bases: Vector1D

y: float

The y-component of the 2D Vector

modelviewprojection.mathutils2d.scale(m_x: float, m_y: float) InvertibleFunction[source]
modelviewprojection.mathutils2d.rotate_90_degrees() InvertibleFunction[source]
modelviewprojection.mathutils2d.rotate(angle_in_radians: float) InvertibleFunction[source]
modelviewprojection.mathutils2d.rotate_around(angle_in_radians: float, center: Vector2D) InvertibleFunction[source]
modelviewprojection.mathutils2d.sine(v1: Vector, v2: Vector) float[source]
modelviewprojection.mathutils2d.is_counter_clockwise(v1: Vector2D, v2: Vector2D) bool[source]
modelviewprojection.mathutils2d.is_clockwise(v1: Vector2D, v2: Vector2D) bool[source]
modelviewprojection.mathutils2d.is_parallel(v1: Vector2D, v2: Vector2D) bool[source]
modelviewprojection.mathutils2d.translate(b: Vector) InvertibleFunction[source]
modelviewprojection.mathutils2d.uniform_scale(m: float) InvertibleFunction[source]
class modelviewprojection.mathutils2d.InvertibleFunction(func: Callable[[Vector], Vector], inverse: Callable[[Vector], Vector])[source]

Bases: object

Class that wraps a function and its inverse function. The function takes type T as it’s argument and it’s evaluation results in a value of type T.

func: Callable[[Vector], Vector]

The wrapped function

inverse: Callable[[Vector], Vector]

The inverse of the wrapped function

modelviewprojection.mathutils2d.inverse(f: InvertibleFunction) InvertibleFunction[source]

Get the inverse of the InvertibleFunction

Parameters:

f – InvertibleFunction: A function with it’s associated inverse function.

Returns:

The Inverse of the function

function.

Return type:

InvertibleFunction

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils import InvertibleFunction
>>> from modelviewprojection.mathutils import inverse
>>> def f(x):
...     return 2 + x
...
>>> def f_inv(x):
...     return x - 2
...
>>> foo = InvertibleFunction(func=f, inverse=f_inv)
>>> foo 
InvertibleFunction(func=<function f at 0x...>, inverse=<function f_inv at 0x...>)
>>> foo(5)
7
>>> inverse(foo) 
InvertibleFunction(func=<function f_inv at 0x...>, inverse=<function f at 0x...>)
>>> inverse(foo)(foo(5))
5
modelviewprojection.mathutils2d.compose(functions: list[InvertibleFunction]) InvertibleFunction[source]

Compose a sequence of functions.

If two functions are passed as arguments, named \(f\) and \(g\):

\((f \circ g)(x) = f(g(x))\).

If \(n\) functions are passed as arguments, \(f_1...f_n\):

\((f_1 \circ (f_2 \circ (... f_n )(x) = f_1(f_2...(f_n(x))\).

Parameters:

functions (list[InvertibleFunction]) – Variable number of InvertibleFunctions to compose. At least on value must be provided.

Returns:

One function that is the aggregate function of the argument

functions composed.

Return type:

Vector

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils import compose
>>> compose([lambda x: 5])(1)
5
>>> compose([lambda x: 2*x])(1)
2
>>> compose([lambda x: x+4, lambda x: 2*x])(1)
6
>>> compose([lambda x: x+ 10, lambda x: x+4, lambda x: 2*x])(1)
16
class modelviewprojection.mathutils2d.Vector[source]

Bases: object

__add__(rhs: Self) Self[source]

Add together two Vectors, component-wise.

Parameters:

rhs (Vector) – The vector on the right hand side of the addition symbol

Returns:

The Vector that represents the additon of the two

input Vectors

Return type:

Vector

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2)
>>> b = Vector1D(x=5)
>>> a + b
Vector1D(x=7)
>>> from modelviewprojection.mathutils2d import Vector2D
>>> a = Vector2D(x=2, y=3)
>>> b = Vector2D(x=5, y=6)
>>> a + b
Vector2D(x=7, y=9)
>>> from modelviewprojection.mathutils3d import Vector3D
>>> a = Vector3D(x=2, y=3, z=1)
>>> b = Vector3D(x=5, y=6, z=10)
>>> a + b
Vector3D(x=7, y=9, z=11)
__mul__(scalar: float) Self[source]

Multiply the Vector by a scalar number, component-wise

Parameters:

rhs (Vector) – The scalar to be multiplied to the Vector’s component subtraction symbol

Returns:

The Vector that represents scalar times the amount of the input

Vector

Return type:

Vector

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2)
>>> a * 4
Vector1D(x=8)
>>> from modelviewprojection.mathutils2d import Vector2D
>>> a = Vector2D(x=2, y=3)
>>> a * 4
Vector2D(x=8, y=12)
>>> from modelviewprojection.mathutils3d import Vector3D
>>> a = Vector3D(x=2, y=3, z=5)
>>> a * 4
Vector3D(x=8, y=12, z=20)
__neg__() Self[source]

Let \(\vec{a}\) and constant \(-1\):

\[-1 * \vec{a}\]

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2.0)
>>> -a
Vector1D(x=-2.0)
__sub__(rhs: Self) Self[source]
\[\vec{a} + -\vec{b}\]

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2.0)
>>> b = Vector1D(x=5.0)
>>> a - b
Vector1D(x=-3.0)
__rmul__(scalar: float) Self[source]
isclose(other: Self) float[source]
component_wise_with_index(other: Self)[source]
dot(other: Self) float[source]

Math Utils 3D

class modelviewprojection.mathutils3d.Vector3D(x: float, y: float, z: float)[source]

Bases: Vector2D

z: float

The z-component of the 3D Vector

cross(rhs: Self) Self[source]
modelviewprojection.mathutils3d.cos(v1: Vector3D, v2: Vector3D) float[source]
modelviewprojection.mathutils3d.abs_sin(v1: Vector3D, v2: Vector3D) float[source]
modelviewprojection.mathutils3d.scale(m_x: float, m_y: float, m_z: float) InvertibleFunction[source]
modelviewprojection.mathutils3d.rotate_x(angle_in_radians: float) InvertibleFunction[source]
modelviewprojection.mathutils3d.rotate_y(angle_in_radians: float) InvertibleFunction[source]
modelviewprojection.mathutils3d.rotate_z(angle_in_radians: float) InvertibleFunction[source]
modelviewprojection.mathutils3d.ortho(left: float, right: float, bottom: float, top: float, near: float, far: float) InvertibleFunction[source]
modelviewprojection.mathutils3d.perspective(field_of_view: float, aspect_ratio: float, near_z: float, far_z: float) InvertibleFunction[source]
modelviewprojection.mathutils3d.cs_to_ndc_space_fn(vector: Vector3D) InvertibleFunction[source]
class modelviewprojection.mathutils3d.FunctionStack(stack: list[modelviewprojection.mathutils.InvertibleFunction] = <factory>)[source]

Bases: object

stack: list[InvertibleFunction]
push(o: InvertibleFunction)[source]
pop() InvertibleFunction[source]
clear()[source]
modelspace_to_ndc_fn() InvertibleFunction[source]
modelviewprojection.mathutils3d.push_transformation(f)[source]
modelviewprojection.mathutils3d.translate(b: Vector) InvertibleFunction[source]
modelviewprojection.mathutils3d.uniform_scale(m: float) InvertibleFunction[source]
class modelviewprojection.mathutils3d.InvertibleFunction(func: Callable[[Vector], Vector], inverse: Callable[[Vector], Vector])[source]

Bases: object

Class that wraps a function and its inverse function. The function takes type T as it’s argument and it’s evaluation results in a value of type T.

func: Callable[[Vector], Vector]

The wrapped function

inverse: Callable[[Vector], Vector]

The inverse of the wrapped function

modelviewprojection.mathutils3d.inverse(f: InvertibleFunction) InvertibleFunction[source]

Get the inverse of the InvertibleFunction

Parameters:

f – InvertibleFunction: A function with it’s associated inverse function.

Returns:

The Inverse of the function

function.

Return type:

InvertibleFunction

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils import InvertibleFunction
>>> from modelviewprojection.mathutils import inverse
>>> def f(x):
...     return 2 + x
...
>>> def f_inv(x):
...     return x - 2
...
>>> foo = InvertibleFunction(func=f, inverse=f_inv)
>>> foo 
InvertibleFunction(func=<function f at 0x...>, inverse=<function f_inv at 0x...>)
>>> foo(5)
7
>>> inverse(foo) 
InvertibleFunction(func=<function f_inv at 0x...>, inverse=<function f at 0x...>)
>>> inverse(foo)(foo(5))
5
modelviewprojection.mathutils3d.compose(functions: list[InvertibleFunction]) InvertibleFunction[source]

Compose a sequence of functions.

If two functions are passed as arguments, named \(f\) and \(g\):

\((f \circ g)(x) = f(g(x))\).

If \(n\) functions are passed as arguments, \(f_1...f_n\):

\((f_1 \circ (f_2 \circ (... f_n )(x) = f_1(f_2...(f_n(x))\).

Parameters:

functions (list[InvertibleFunction]) – Variable number of InvertibleFunctions to compose. At least on value must be provided.

Returns:

One function that is the aggregate function of the argument

functions composed.

Return type:

Vector

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils import compose
>>> compose([lambda x: 5])(1)
5
>>> compose([lambda x: 2*x])(1)
2
>>> compose([lambda x: x+4, lambda x: 2*x])(1)
6
>>> compose([lambda x: x+ 10, lambda x: x+4, lambda x: 2*x])(1)
16
class modelviewprojection.mathutils3d.Vector[source]

Bases: object

__add__(rhs: Self) Self[source]

Add together two Vectors, component-wise.

Parameters:

rhs (Vector) – The vector on the right hand side of the addition symbol

Returns:

The Vector that represents the additon of the two

input Vectors

Return type:

Vector

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2)
>>> b = Vector1D(x=5)
>>> a + b
Vector1D(x=7)
>>> from modelviewprojection.mathutils2d import Vector2D
>>> a = Vector2D(x=2, y=3)
>>> b = Vector2D(x=5, y=6)
>>> a + b
Vector2D(x=7, y=9)
>>> from modelviewprojection.mathutils3d import Vector3D
>>> a = Vector3D(x=2, y=3, z=1)
>>> b = Vector3D(x=5, y=6, z=10)
>>> a + b
Vector3D(x=7, y=9, z=11)
__mul__(scalar: float) Self[source]

Multiply the Vector by a scalar number, component-wise

Parameters:

rhs (Vector) – The scalar to be multiplied to the Vector’s component subtraction symbol

Returns:

The Vector that represents scalar times the amount of the input

Vector

Return type:

Vector

Raises:

Nothing

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2)
>>> a * 4
Vector1D(x=8)
>>> from modelviewprojection.mathutils2d import Vector2D
>>> a = Vector2D(x=2, y=3)
>>> a * 4
Vector2D(x=8, y=12)
>>> from modelviewprojection.mathutils3d import Vector3D
>>> a = Vector3D(x=2, y=3, z=5)
>>> a * 4
Vector3D(x=8, y=12, z=20)
__neg__() Self[source]

Let \(\vec{a}\) and constant \(-1\):

\[-1 * \vec{a}\]

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2.0)
>>> -a
Vector1D(x=-2.0)
__sub__(rhs: Self) Self[source]
\[\vec{a} + -\vec{b}\]

Example

>>> from modelviewprojection.mathutils1d import Vector1D
>>> a = Vector1D(x=2.0)
>>> b = Vector1D(x=5.0)
>>> a - b
Vector1D(x=-3.0)
__rmul__(scalar: float) Self[source]
isclose(other: Self) float[source]
component_wise_with_index(other: Self)[source]
dot(other: Self) float[source]