satsim.vecmath package

Submodules

satsim.vecmath.Cartesian2 module

class satsim.vecmath.Cartesian2.Cartesian2(x=0.0, y=0.0)

Bases: object

A 2D Cartesian point.

static ONE()

A Cartesian2 instance initialized to (1.0, 1.0).

static UNIT_X()

A Cartesian2 instance initialized to (1.0, 0.0).

static UNIT_Y()

A Cartesian2 instance initialized to (0.0, 1.0).

static ZERO()

A Cartesian2 instance initialized to (0.0, 0.0).

static abs(cartesian, result)

Computes the absolute value of the provided Cartesian.

Parameters:
  • cartesian

  • Cartesian2

  • computed. (The Cartesian whose absolute value is to be) –

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter.

static add(left, right, result)

Computes the component wise sum of two Cartesians.

Parameters:
  • left

  • Cartesian2

  • Cartesian. (The second) –

  • right

  • Cartesian2

  • Cartesian.

  • resultCartesian2, The object onto which to store the result.

Returns:

A float, The modified result parameter.

static angleBetween(left, right)

Returns the angle, in radians, between the provided Cartesians.

Parameters:
  • left

  • Cartesian2

  • Cartesian. (The second) –

  • right

  • Cartesian2

  • Cartesian.

Returns:

A float, The angle between the Cartesians.

static clamp(value, min_val, max_val, result)

Computes the value of the minimum component for the supplied Cartesian.

Parameters:
  • valueCartesian2, The value to clamp.

  • min_valCartesian2, The minimum bound.

  • max_valCartesian2, The maximum bound.

  • resultCartesian2, The object onto which to store the result.

Returns:

A number, The clamped value such that min <= result <= max.

static clone(cartesian=None, result=None)

Duplicates a Cartesian2 instance.

Parameters:
  • cartesianCartesian2, The cartesian to duplicate.

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter or a new Cartesian2 instance if one was not provided.

static cross(left, right)

Computes the magnitude of the cross product that would result from implicitly setting the Z coordinate of the input vectors to 0.

Parameters:
  • left

  • Cartesian2

  • Cartesian. (The second) –

  • right

  • Cartesian2

  • Cartesian.

Returns:

A float, The cross product.

static distance(left, right)

Computes the distance between two points.

Parameters:
  • left

  • Cartesian2

  • from. (The first point to compute the distance) –

  • right

  • Cartesian2

  • to. (The second point to compute the distance) –

Returns:

A float, The distance between two points.

static distanceSquared(left, right)

Computes the squared distance between two points. Comparing squared distances using this function is more efficient than comparing distances.

Parameters:
  • left

  • Cartesian2

  • from. (The first point to compute the distance) –

  • right

  • Cartesian2

  • to. (The second point to compute the distance) –

Returns:

A float, The distance between two points.

static divideByScalar(cartesian, scalar, result)

Divides the provided Cartesian componentwise by the provided scalar.

Parameters:
  • cartesian

  • Cartesian2

  • divided. (The Cartesian to be) –

  • scalar

  • float

  • by. (The scalar to divide) –

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter.

static divideComponents(left, right, result)

Computes the component wise quotient of two Cartesians.

Parameters:
  • left

  • Cartesian2

  • Cartesian. (The second) –

  • right

  • Cartesian2

  • Cartesian.

  • resultCartesian2, The object onto which to store the result.

Returns:

A float, The modified result parameter.

static dot(left, right)

Computes the dot (scalar) product of two Cartesians.

Parameters:
  • left

  • Cartesian2

  • Cartesian. (The second) –

  • right

  • Cartesian2

  • Cartesian.

Returns:

A float, The dot product.

static equals(left, right)

Compares the provided Cartesians componentwise and return True if equal, False otherwise.

Parameters:
  • left

  • Cartesian2

  • Cartesian. (The first) –

  • rightCartesian2, The second Cartesian.

Returns:

A boolean, True if equal, False otherwise.

static equalsEpsilon(left, right, relativeEpsilon=0.0, absoluteEpsilon=0.0)

Compares the provided Cartesians componentwise and return True if they pass an absolute or relative tolerance test, False otherwise.

Parameters:
  • left

  • Cartesian2

  • Cartesian. (The first) –

  • rightCartesian2, The second Cartesian.

  • relativeEpsilon

  • float

  • default=0 (The absolute epsilon tolerance to use for equality testing.) –

  • absoluteEpsilon

  • float

  • default=0

Returns:

A boolean, True if they pass an absolute or relative tolerance test, False otherwise.

static fromArray(array, startingIndex=0, result=None)

Creates a Cartesian2 from two consecutive elements in an array.

Parameters:
  • arraylist, The array whose two consecutive elements correspond to the x and y components, respectively.

  • startingIndexint, The offset into the array of the first element, which corresponds to the x component.

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter or a new Cartesian2 instance if one was not provided.

static fromCartesian3(cartesian, result=None)

Creates a Cartesian2 instance from an existing Cartesian3. This simply takes the x and y properties of the Cartesian3 and drops z.

Parameters:
  • cartesianCartesian3, The cartesian to create from.

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter or a new Cartesian2 instance if one was not provided.

static fromCartesian4(cartesian, result=None)

Creates a Cartesian2 instance from an existing Cartesian3. This simply takes the x and y properties of the Cartesian3 and drops z and w.

Parameters:
  • cartesianCartesian4, The cartesian to create from.

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter or a new Cartesian2 instance if one was not provided.

static fromElements(x, y, result=None)

Creates a Cartesian2 instance from x and y coordinates.

Parameters:
  • xfloat, The X component. default: 0

  • yfloat, The Y component. default: 0

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter or a new Cartesian2 instance if one was not provided.

static lerp(start, end, t, result)

Computes the linear interpolation or extrapolation at t using the provided cartesians.

Parameters:
  • start

  • Cartesian2

  • 0.0. (The value corresponding to t at) –

  • end

  • Cartesian2

  • 1.0. (The value corresponding to t at) –

  • t

  • Cartesian2

  • interpolate. (The point along t at which to) –

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter.

static magnitude(cartesian)

Computes the provided Cartesian’s magnitude (length).

Parameters:

cartesianCartesian2, he Cartesian instance whose magnitude is to be computed.

Returns:

A float, The magnitude.

static magnitudeSquared(cartesian)

Computes the provided Cartesian’s squared magnitude.

Parameters:

cartesianCartesian2, he Cartesian instance whose squared magnitude is to be computed.

Returns:

A float, The squared magnitude.

static maximumByComponent(first, second, result)

Computes the value of the maximum component for the supplied Cartesian.

Parameters:
  • firstCartesian2, The cartesian to compare.

  • secondCartesian2, The cartesian to compare.

  • resultCartesian2, The object onto which to store the result.

Returns:

A number, The value of the maximum component.

static maximumComponent(cartesian)

Computes the value of the maximum component for the supplied Cartesian.

Parameters:

cartesianCartesian2, The cartesian to use.

Returns:

A number, The value of the maximum component.

static minimumByComponent(first, second, result)

Computes the value of the minimum component for the supplied Cartesian.

Parameters:
  • firstCartesian2, The cartesian to compare.

  • secondCartesian2, The cartesian to compare.

  • resultCartesian2, The object onto which to store the result.

Returns:

A number, The value of the minimum component.

static minimumComponent(cartesian)

Computes the value of the minimum component for the supplied Cartesian.

Parameters:

cartesianCartesian2, The cartesian to use.

Returns:

A number, The value of the minimum component.

static mostOrthogonalAxis(cartesian, result)

Returns the angle, in radians, between the provided Cartesians.

Parameters:
  • cartesian

  • Cartesian2

  • axis. (The Cartesian on which to find the most orthogonal) –

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The most orthogonal axis.

static multiplyByScalar(cartesian, scalar, result)

Multiplies the provided Cartesian componentwise by the provided scalar.

Parameters:
  • cartesian

  • Cartesian2

  • scaled. (The Cartesian to be) –

  • scalar

  • float

  • with. (The scalar to multiply) –

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter.

static multiplyComponents(left, right, result)

Computes the componentwise product of two Cartesians.

Parameters:
  • left

  • Cartesian2

  • Cartesian. (The second) –

  • right

  • Cartesian2

  • Cartesian.

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter.

static negate(cartesian, result)

Negates the provided Cartesian.

Parameters:
  • cartesian

  • Cartesian2

  • negated. (The Cartesian to be) –

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter.

static normalize(cartesian, result)

Computes the normalized form of the supplied Cartesian.

Parameters:
  • cartesian

  • Cartesian2

  • normalized. (The Cartesian to be) –

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter.

static subtract(left, right, result)

Computes the component wise difference of two Cartesians.

Parameters:
  • left

  • Cartesian2

  • Cartesian. (The second) –

  • right

  • Cartesian2

  • Cartesian.

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter.

satsim.vecmath.Cartesian3 module

class satsim.vecmath.Cartesian3.Cartesian3(x=0.0, y=0.0, z=0.0)

Bases: object

A 3D Cartesian point.

static ONE()

A Cartesian3 instance initialized to (1.0, 1.0, 1.0).

static UNIT_X()

A Cartesian3 instance initialized to (1.0, 0.0, 0.0).

static UNIT_Y()

A Cartesian3 instance initialized to (0.0, 1.0, 0.0).

static UNIT_Z()

A Cartesian3 instance initialized to (0.0, 0.0, 1.0).

static ZERO()

A Cartesian3 instance initialized to (0.0, 0.0, 0.0).

static abs(cartesian, result)

Computes the absolute value of the provided Cartesian.

Parameters:
  • cartesian

  • Cartesian3

  • computed. (The Cartesian whose absolute value is to be) –

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter.

static add(left, right, result)

Computes the component wise sum of two Cartesians.

Parameters:
  • left

  • Cartesian3

  • Cartesian. (The second) –

  • right

  • Cartesian3

  • Cartesian.

  • resultCartesian3, The object onto which to store the result.

Returns:

A float, The modified result parameter.

static angleBetween(left, right)

Returns the angle, in radians, between the provided Cartesians.

Parameters:
  • left

  • Cartesian3

  • Cartesian. (The second) –

  • right

  • Cartesian3

  • Cartesian.

Returns:

A float, The angle between the Cartesians.

static clamp(value, min_val, max_val, result)

Computes the value of the minimum component for the supplied Cartesian.

Parameters:
  • valueCartesian3, The value to clamp.

  • min_valCartesian3, The minimum bound.

  • max_valCartesian3, The maximum bound.

  • resultCartesian3, The object onto which to store the result.

Returns:

A number, The clamped value such that min <= result <= max.

static clone(cartesian=None, result=None)

Duplicates a Cartesian3 instance.

Parameters:
  • cartesianCartesian3, The cartesian to duplicate.

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter or a new Cartesian3 instance if one was not provided.

static cross(left, right, result)

Computes the magnitude of the cross product that would result from implicitly setting the Z coordinate of the input vectors to 0.

Parameters:
  • left

  • Cartesian3

  • Cartesian. (The second) –

  • right

  • Cartesian3

  • Cartesian.

Returns:

A float, The cross product.

static distance(left, right)

Computes the distance between two points.

Parameters:
  • left

  • Cartesian3

  • from. (The first point to compute the distance) –

  • right

  • Cartesian3

  • to. (The second point to compute the distance) –

Returns:

A float, The distance between two points.

static distanceSquared(left, right)

Computes the squared distance between two points. Comparing squared distances using this function is more efficient than comparing distances.

Parameters:
  • left

  • Cartesian3

  • from. (The first point to compute the distance) –

  • right

  • Cartesian3

  • to. (The second point to compute the distance) –

Returns:

A float, The distance between two points.

static divideByScalar(cartesian, scalar, result)

Divides the provided Cartesian componentwise by the provided scalar.

Parameters:
  • cartesian

  • Cartesian3

  • divided. (The Cartesian to be) –

  • scalar

  • float

  • by. (The scalar to divide) –

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter.

static divideComponents(left, right, result)

Computes the component wise quotient of two Cartesians.

Parameters:
  • left

  • Cartesian3

  • Cartesian. (The second) –

  • right

  • Cartesian3

  • Cartesian.

  • resultCartesian3, The object onto which to store the result.

Returns:

A float, The modified result parameter.

static dot(left, right)

Computes the dot (scalar) product of two Cartesians.

Parameters:
  • left

  • Cartesian3

  • Cartesian. (The second) –

  • right

  • Cartesian3

  • Cartesian.

Returns:

A float, The dot product.

static equals(left, right)

Compares the provided Cartesians componentwise and return True if equal, False otherwise

Parameters:
  • left

  • Cartesian3

  • Cartesian. (The first) –

  • rightCartesian3, The second Cartesian.

Returns:

A boolean, True if equal, False otherwise.

static equalsEpsilon(left, right, relativeEpsilon=0.0, absoluteEpsilon=0.0)

Compares the provided Cartesians componentwise and return True if they pass an absolute or relative tolerance test, False otherwise.

Parameters:
  • left

  • Cartesian3

  • Cartesian. (The first) –

  • rightCartesian3, The second Cartesian.

  • relativeEpsilon

  • float

  • default=0 (The absolute epsilon tolerance to use for equality testing.) –

  • absoluteEpsilon

  • float

  • default=0

Returns:

A boolean, True if they pass an absolute or relative tolerance test, False otherwise.

static fromArray(array, startingIndex=0, result=None)

Creates a Cartesian3 from three consecutive elements in an array.

Parameters:
  • arraylist, The array whose three consecutive elements correspond to the x, y, and z components, respectively.

  • startingIndexint, The offset into the array of the first element, which corresponds to the x component.

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter or a new Cartesian3 instance if one was not provided.

static fromCartesian4(cartesian)

Creates a Cartesian3 instance from an existing Cartesian3. This simply takes the x and y properties of the Cartesian3 and drops z and w.

Parameters:
  • cartesianCartesian4, The cartesian to create from.

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter or a new Cartesian3 instance if one was not provided.

static fromElements(x, y, z, result=None)

Creates a Cartesian3 instance from x and y coordinates.

Parameters:
  • xfloat, The X component. default: 0

  • yfloat, The Y component. default: 0

  • zfloat, The Z component. default: 0

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter or a new Cartesian3 instance if one was not provided.

static fromSpherical(spherical, result=None)

Converts the provided Spherical into Cartesian3 coordinates.

Parameters:
  • sphericaldict, The Spherical to be converted to Cartesian3.

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter or a new Cartesian3 instance if one was not provided.

static lerp(start, end, t, result)

Computes the linear interpolation or extrapolation at t using the provided cartesians.

Parameters:
  • start

  • Cartesian3

  • 0.0. (The value corresponding to t at) –

  • end

  • Cartesian3

  • 1.0. (The value corresponding to t at) –

  • t

  • Cartesian3

  • interpolate. (The point along t at which to) –

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter.

static magnitude(cartesian)

Computes the provided Cartesian’s magnitude (length).

Parameters:

cartesianCartesian3, he Cartesian instance whose magnitude is to be computed.

Returns:

A float, The magnitude.

static magnitudeSquared(cartesian)

Computes the provided Cartesian’s squared magnitude.

Parameters:

cartesianCartesian3, he Cartesian instance whose squared magnitude is to be computed.

Returns:

A float, The squared magnitude.

static maximumByComponent(first, second, result)

Computes the value of the maximum component for the supplied Cartesian.

Parameters:
  • firstCartesian3, The cartesian to compare.

  • secondCartesian3, The cartesian to compare.

  • resultCartesian3, The object onto which to store the result.

Returns:

A number, The value of the maximum component.

static maximumComponent(cartesian)

Computes the value of the maximum component for the supplied Cartesian.

Parameters:

cartesianCartesian3, The cartesian to use.

Returns:

A number, The value of the maximum component.

static midpoint(left, right, result)

Computes the midpoint between the right and left Cartesian.

Parameters:
  • left

  • Cartesian3

  • Cartesian. (The first) –

  • rightCartesian3, The second Cartesian.

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The midpoint.

static minimumByComponent(first, second, result)

Computes the value of the minimum component for the supplied Cartesian.

Parameters:
  • firstCartesian3, The cartesian to compare.

  • secondCartesian3, The cartesian to compare.

  • resultCartesian3, The object onto which to store the result.

Returns:

A number, The value of the minimum component.

static minimumComponent(cartesian)

Computes the value of the minimum component for the supplied Cartesian.

Parameters:

cartesianCartesian3, The cartesian to use.

Returns:

A number, The value of the minimum component.

static mostOrthogonalAxis(cartesian, result)

Returns the angle, in radians, between the provided Cartesians.

Parameters:
  • cartesian

  • Cartesian3

  • axis. (The Cartesian on which to find the most orthogonal) –

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The most orthogonal axis.

static multiplyByScalar(cartesian, scalar, result)

Multiplies the provided Cartesian componentwise by the provided scalar.

Parameters:
  • cartesian

  • Cartesian3

  • scaled. (The Cartesian to be) –

  • scalar

  • float

  • with. (The scalar to multiply) –

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter.

static multiplyComponents(left, right, result)

Computes the componentwise product of two Cartesians.

Parameters:
  • left

  • Cartesian3

  • Cartesian. (The second) –

  • right

  • Cartesian3

  • Cartesian.

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter.

static negate(cartesian, result)

Negates the provided Cartesian.

Parameters:
  • cartesian

  • Cartesian3

  • negated. (The Cartesian to be) –

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter.

static normalize(cartesian, result)

Computes the normalized form of the supplied Cartesian.

Parameters:
  • cartesian

  • Cartesian3

  • normalized. (The Cartesian to be) –

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter.

static projectVector(a, b, result)

Projects vector a onto vector b.

Parameters:
  • a

  • Cartesian3

  • projecting. (The vector that needs) –

  • bCartesian3, The vector to project onto.

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter.

static subtract(left, right, result)

Computes the component wise difference of two Cartesians.

Parameters:
  • left

  • Cartesian3

  • Cartesian. (The second) –

  • right

  • Cartesian3

  • Cartesian.

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter.

satsim.vecmath.Cartesian4 module

class satsim.vecmath.Cartesian4.Cartesian4(x=0.0, y=0.0, z=0.0, w=0.0)

Bases: object

A 4D Cartesian point.

static ONE()

A Cartesian4 instance initialized to (1.0, 1.0, 1.0, 1.0).

static UNIT_W()

A Cartesian4 instance initialized to (0.0, 0.0, 0.0, 1.0).

static UNIT_X()

A Cartesian4 instance initialized to (1.0, 0.0, 0.0, 0.0).

static UNIT_Y()

A Cartesian4 instance initialized to (0.0, 1.0, 0.0, 0.0).

static UNIT_Z()

A Cartesian4 instance initialized to (0.0, 0.0, 1.0, 0.0).

static ZERO()

A Cartesian4 instance initialized to (0.0, 0.0, 0.0, 0.0).

static abs(cartesian, result)

Computes the absolute value of the provided Cartesian.

Parameters:
  • cartesian

  • Cartesian4

  • computed. (The Cartesian whose absolute value is to be) –

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The modified result parameter.

static add(left, right, result)

Computes the component wise sum of two Cartesians.

Parameters:
  • left

  • Cartesian4

  • Cartesian. (The second) –

  • right

  • Cartesian4

  • Cartesian.

  • resultCartesian4, The object onto which to store the result.

Returns:

A float, The modified result parameter.

static clamp(value, min_val, max_val, result)

Computes the value of the minimum component for the supplied Cartesian.

Parameters:
  • valueCartesian4, The value to clamp.

  • min_valCartesian4, The minimum bound.

  • max_valCartesian4, The maximum bound.

  • resultCartesian4, The object onto which to store the result.

Returns:

A number, The clamped value such that min <= result <= max.

static clone(cartesian=None, result=None)

Duplicates a Cartesian4 instance.

Parameters:
  • cartesianCartesian4, The cartesian to duplicate.

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The modified result parameter or a new Cartesian4 instance if one was not provided.

static distance(left, right)

Computes the distance between two points.

Parameters:
  • left

  • Cartesian4

  • from. (The first point to compute the distance) –

  • right

  • Cartesian4

  • to. (The second point to compute the distance) –

Returns:

A float, The distance between two points.

static distanceSquared(left, right)

Computes the squared distance between two points. Comparing squared distances using this function is more efficient than comparing distances.

Parameters:
  • left

  • Cartesian4

  • from. (The first point to compute the distance) –

  • right

  • Cartesian4

  • to. (The second point to compute the distance) –

Returns:

A float, The distance between two points.

static divideByScalar(cartesian, scalar, result)

Divides the provided Cartesian componentwise by the provided scalar.

Parameters:
  • cartesian

  • Cartesian4

  • divided. (The Cartesian to be) –

  • scalar

  • float

  • by. (The scalar to divide) –

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The modified result parameter.

static divideComponents(left, right, result)

Computes the component wise quotient of two Cartesians.

Parameters:
  • left

  • Cartesian4

  • Cartesian. (The second) –

  • right

  • Cartesian4

  • Cartesian.

  • resultCartesian4, The object onto which to store the result.

Returns:

A float, The modified result parameter.

static dot(left, right)

Computes the dot (scalar) product of two Cartesians.

Parameters:
  • left

  • Cartesian4

  • Cartesian. (The second) –

  • right

  • Cartesian4

  • Cartesian.

Returns:

A float, The dot product.

static equals(left, right)

Compares the provided Cartesians componentwise and return True if equal, False otherwise

Parameters:
  • left

  • Cartesian4

  • Cartesian. (The first) –

  • rightCartesian4, The second Cartesian.

Returns:

A boolean, True if equal, False otherwise.

static equalsEpsilon(left, right, relativeEpsilon=0.0, absoluteEpsilon=0.0)

Compares the provided Cartesians componentwise and return True if they pass an absolute or relative tolerance test, False otherwise.

Parameters:
  • left

  • Cartesian4

  • Cartesian. (The first) –

  • rightCartesian4, The second Cartesian.

  • relativeEpsilon

  • float

  • default=0 (The absolute epsilon tolerance to use for equality testing.) –

  • absoluteEpsilon

  • float

  • default=0

Returns:

A boolean, True if they pass an absolute or relative tolerance test, False otherwise.

static fromArray(array, startingIndex=0, result=None)

Creates a Cartesian4 from four consecutive elements in an array.

Parameters:
  • arraylist, The array whose four consecutive elements correspond to the x y, z, and w components, respectively.

  • startingIndexint, The offset into the array of the first element, which corresponds to the x component.

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The modified result parameter or a new Cartesian4 instance if one was not provided.

static fromElements(x, y, z, w, result=None)

Creates a Cartesian4 instance from x and y coordinates.

Parameters:
  • xfloat, The X component. default: 0

  • yfloat, The Y component. default: 0

  • zfloat, The Z component. default: 0

  • wfloat, The W component. default: 0

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The modified result parameter or a new Cartesian4 instance if one was not provided.

static lerp(start, end, t, result)

Computes the linear interpolation or extrapolation at t using the provided cartesians.

Parameters:
  • start

  • Cartesian4

  • 0.0. (The value corresponding to t at) –

  • end

  • Cartesian4

  • 1.0. (The value corresponding to t at) –

  • t

  • Cartesian4

  • interpolate. (The point along t at which to) –

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The modified result parameter.

static magnitude(cartesian)

Computes the provided Cartesian’s magnitude (length).

Parameters:

cartesianCartesian4, he Cartesian instance whose magnitude is to be computed.

Returns:

A float, The magnitude.

static magnitudeSquared(cartesian)

Computes the provided Cartesian’s squared magnitude.

Parameters:

cartesianCartesian4, he Cartesian instance whose squared magnitude is to be computed.

Returns:

A float, The squared magnitude.

static maximumByComponent(first, second, result)

Computes the value of the maximum component for the supplied Cartesian.

Parameters:
  • firstCartesian4, The cartesian to compare.

  • secondCartesian4, The cartesian to compare.

  • resultCartesian4, The object onto which to store the result.

Returns:

A number, The value of the maximum component.

static maximumComponent(cartesian)

Computes the value of the maximum component for the supplied Cartesian.

Parameters:

cartesianCartesian4, The cartesian to use.

Returns:

A number, The value of the maximum component.

static minimumByComponent(first, second, result)

Computes the value of the minimum component for the supplied Cartesian.

Parameters:
  • firstCartesian4, The cartesian to compare.

  • secondCartesian4, The cartesian to compare.

  • resultCartesian4, The object onto which to store the result.

Returns:

A number, The value of the minimum component.

static minimumComponent(cartesian)

Computes the value of the minimum component for the supplied Cartesian.

Parameters:

cartesianCartesian4, The cartesian to use.

Returns:

A number, The value of the minimum component.

static mostOrthogonalAxis(cartesian, result)

Returns the angle, in radians, between the provided Cartesians.

Parameters:
  • cartesian

  • Cartesian4

  • axis. (The Cartesian on which to find the most orthogonal) –

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The most orthogonal axis.

static multiplyByScalar(cartesian, scalar, result)

Multiplies the provided Cartesian componentwise by the provided scalar.

Parameters:
  • cartesian

  • Cartesian4

  • scaled. (The Cartesian to be) –

  • scalar

  • float

  • with. (The scalar to multiply) –

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The modified result parameter.

static multiplyComponents(left, right, result)

Computes the componentwise product of two Cartesians.

Parameters:
  • left

  • Cartesian4

  • Cartesian. (The second) –

  • right

  • Cartesian4

  • Cartesian.

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The modified result parameter.

static negate(cartesian, result)

Negates the provided Cartesian.

Parameters:
  • cartesian

  • Cartesian4

  • negated. (The Cartesian to be) –

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The modified result parameter.

static normalize(cartesian, result)

Computes the normalized form of the supplied Cartesian.

Parameters:
  • cartesian

  • Cartesian4

  • normalized. (The Cartesian to be) –

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The modified result parameter.

static subtract(left, right, result)

Computes the component wise difference of two Cartesians.

Parameters:
  • left

  • Cartesian4

  • Cartesian. (The second) –

  • right

  • Cartesian4

  • Cartesian.

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The modified result parameter.

satsim.vecmath.Matrix2 module

class satsim.vecmath.Matrix2.Matrix2(column0Row0=0.0, column1Row0=0.0, column0Row1=0.0, column1Row1=0.0)

Bases: object

A 2x2 matrix, indexable as a column-major order array. Constructor parameters are in row-major order for code readability.

COLUMN0ROW0 = 0
COLUMN0ROW1 = 1
COLUMN1ROW0 = 2
COLUMN1ROW1 = 3
static IDENTITY()

A Matrix2 initialized to the identity matrix.

static ZERO()

A Matrix2 initialized to the zero matrix.

static abs(matrix, result)

Computes a matrix, which contains the absolute (unsigned) values of the provided matrix’s elements.

Parameters:
  • matrix

  • Matrix2

  • elements. (The matrix with signed) –

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

static add(left, right, result)

Computes the sum of two matrices.

Parameters:
  • leftMatrix2, The first matrix.

  • rightMatrix2, The second matrix.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

static clone(matrix=None, result=None)

Duplicates a Matrix2 instance.

Parameters:
  • matrixMatrix2, The cartesian to duplicate.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter or a new Matrix2 instance if one was not provided.

static equalsEpsilon(left, right, epsilon)

Compares the provided matrices componentwise and return True if they pass an absolute or relative tolerance test, False otherwise.

Parameters:
  • left

  • Matrix2

  • Cartesian. (The first) –

  • rightMatrix2, The second Cartesian.

  • epsilon

  • float

  • testing. (The epsilon to use for equality) –

Returns:

A boolean, True if they pass an absolute or relative tolerance test, False otherwise.

static fromArray(array, startingIndex=0, result=None)

Creates a Matrix2 from 4 consecutive elements in an array.

Parameters:
  • arraylist, The array whose 4 consecutive elements correspond to the positions of the matrix. Assumes column-major order.

  • startingIndexint, The offset into the array of the first element, which corresponds to the x component.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter or a new Matrix2 instance if one was not provided.

static fromColumnMajorArray(values, result=None)

Creates a Matrix2 from a column-major order array. The resulting matrix will be in column-major order.

Parameters:
  • arraylist, The column-major order array.

  • startingIndexint, The offset into the array of the first element, which corresponds to the x component.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter or a new Matrix2 instance if one was not provided.

static fromRotation(angle, result=None)

Creates a rotation matrix.

Parameters:
  • anglefloat, The angle, in radians, of the rotation. Positive angles are counterclockwise.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter or a new Matrix2 instance if one was not provided.

static fromRowMajorArray(values, result=None)

Creates a Matrix2 from a row-major order array. The resulting matrix will be in column-major order.

Parameters:
  • arraylist, The row-major order array.

  • startingIndexint, The offset into the array of the first element, which corresponds to the x component.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter or a new Matrix2 instance if one was not provided.

static fromScale(scale, result=None)

Computes a Matrix2 instance representing a non-uniform scale.

Parameters:
  • scaleCartesian2, The x and y scale factors.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter or a new Matrix2 instance if one was not provided.

static fromUniformScale(scale, result=None)

Computes a Matrix2 instance representing a uniform scale.

Parameters:
  • scalefloat, The uniform scale factor.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter or a new Matrix2 instance if one was not provided.

static getColumn(matrix, index, result)

Retrieves a copy of the matrix column at the provided index as a Cartesian2 instance.

Parameters:
  • matrixMatrix2, The matrix to use.

  • indexint, The zero-based index of the column to retrieve.

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter.

static getElementIndex(column, row)

Computes the array index of the element at the provided row and column.

Parameters:
  • rowint, The zero-based index of the row.

  • columnint, The zero-based index of the column.

Returns:

A int, The index of the element at the provided row and column.

static getMaximumScale(matrix)

Computes the maximum scale assuming the matrix is an affine transformation. The maximum scale is the maximum length of the column vectors.

Parameters:

matrixMatrix2, The matrix.

Returns:

A float, The maximum scale.

static getRotation(matrix, result)

Extracts the rotation matrix assuming the matrix is an affine transformation.

Parameters:
  • matrixMatrix2, The matrix.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

static getRow(matrix, index, result)

Retrieves a copy of the matrix row at the provided index as a Cartesian2 instance.

Parameters:
  • matrixMatrix2, The matrix to use.

  • indexint, The zero-based index of the row to retrieve.

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter.

static getScale(matrix, result)

Extracts the non-uniform scale assuming the matrix is an affine transformation.

Parameters:
  • matrixMatrix2, The matrix.

  • resultCartesian2, The object onto which to store the result.

Returns:

A Cartesian2, The modified result parameter.

static multiply(left, right, result)

Computes the product of two matrices.

Parameters:
  • leftMatrix2, The first matrix.

  • rightMatrix2, The second matrix.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

static multiplyByScalar(matrix, scalar, result)

Computes the product of a matrix and a column vector.

Parameters:
  • matrixMatrix2, The first matrix.

  • scalarfloat, The number to multiply by.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

static multiplyByScale(matrix, scale, result)

Computes the product of a matrix times a (non-uniform) scale, as if the scale were a scale matrix.

Parameters:
  • matrixMatrix2, The first matrix.

  • scaleCartesian2, The non-uniform scale on the right-hand side.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

static multiplyByUniformScale(matrix, scale, result)

Computes the product of a matrix times a uniform scale, as if the scale were a scale matrix.

Parameters:
  • matrixMatrix2, The first matrix.

  • scalefloat, The uniform scale on the right-hand side.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

static multiplyByVector(matrix, cartesian, result)

Computes the product of a matrix and a column vector.

Parameters:
  • matrixMatrix2, The first matrix.

  • cartesianCartesian2, The column.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

static negate(matrix, result)

Negates the provided matrix.

Parameters:
  • matrix

  • Matrix2

  • negated. (The matrix to be) –

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

packedLength = 4
static setColumn(matrix, index, cartesian, result)

Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian2 instance.

Parameters:
  • matrixMatrix2, The matrix to use.

  • indexint, The zero-based index of the column to retrieve.

  • cartesianCartesian2, The Cartesian whose values will be assigned to the specified column.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

static setRotation(matrix, rotation, result)

Sets the rotation assuming the matrix is an affine transformation.

Parameters:
  • matrixMatrix2, The matrix to use.

  • rotationMatrix2, The rotation matrix.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

static setRow(matrix, index, cartesian, result)

Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian2 instance.

Parameters:
  • matrixMatrix2, The matrix to use.

  • indexint, The zero-based index of the row to retrieve.

  • cartesianCartesian2, The Cartesian whose values will be assigned to the specified row.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

static setScale(matrix, scale, result)

Computes a new matrix that replaces the scale with the provided scale. This assumes the matrix is an affine transformation.

Parameters:
  • matrixMatrix2, The matrix to use.

  • scaleCartesian2, The scale that replaces the scale of the provided matrix.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

static setUniformScale(matrix, scale, result)

Computes a new matrix that replaces the scale with the provided uniform scale. This assumes the matrix is an affine transformation.

Parameters:
  • matrixMatrix2, The matrix to use.

  • scalefloat, The uniform scale that replaces the scale of the provided matrix.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

static subtract(left, right, result)

Computes the difference of two matrices.

Parameters:
  • leftMatrix2, The first matrix.

  • rightMatrix2, The second matrix.

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

static toArray(matrix, result=None)

Creates an Array from the provided Matrix2 instance. The array will be in column-major order.

Parameters:
  • matrixMatrix2, The matrix to use.

  • resultlist, The Array onto which to store the result.

Returns:

A list, The modified Array parameter or a new Array instance if one was not provided.

static transpose(matrix, result)

Computes the transpose of the provided matrix.

Parameters:
  • matrix

  • Matrix2

  • transpose. (The matrix to be) –

  • resultMatrix2, The object onto which to store the result.

Returns:

A Matrix2, The modified result parameter.

satsim.vecmath.Matrix3 module

class satsim.vecmath.Matrix3.Matrix3(column0Row0=0.0, column1Row0=0.0, column2Row0=0.0, column0Row1=0.0, column1Row1=0.0, column2Row1=0.0, column0Row2=0.0, column1Row2=0.0, column2Row2=0.0)

Bases: object

A 3x3 matrix, indexable as a column-major order array. Constructor parameters are in row-major order for code readability.

COLUMN0ROW0 = 0
COLUMN0ROW1 = 1
COLUMN0ROW2 = 2
COLUMN1ROW0 = 3
COLUMN1ROW1 = 4
COLUMN1ROW2 = 5
COLUMN2ROW0 = 6
COLUMN2ROW1 = 7
COLUMN2ROW2 = 8
static IDENTITY()

A Matrix3 initialized to the identity matrix.

static ZERO()

A Matrix3 initialized to the zero matrix.

static abs(matrix, result)

Computes a matrix, which contains the absolute (unsigned) values of the provided matrix’s elements.

Parameters:
  • matrix

  • Matrix3

  • elements. (The matrix with signed) –

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static add(left, right, result)

Computes the sum of two matrices.

Parameters:
  • leftMatrix3, The first matrix.

  • rightMatrix3, The second matrix.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static clone(matrix=None, result=None)

Creates a Matrix3 from 9 consecutive elements in an array.

Parameters:
  • arraylist, The array whose 9 consecutive elements correspond to the positions of the matrix. Assumes column-major order.

  • startingIndexint, The offset into the array of the first element, which corresponds to the x component.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter or a new Matrix3 instance if one was not provided.

static computeEigenDecomposition(matrix, result=None)

Computes the eigenvectors and eigenvalues of a symmetric matrix.

Parameters:
  • matrix

  • Matrix3

  • symmetric. (The matrix to decompose into diagonal and unitary matrix. Expected to be) –

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static computeFrobeniusNorm(matrix)

Computes the Frobenius norm.

Parameters:
  • matrix

  • Matrix3

  • computed. (The matrix to be) –

Returns:

A float, The Frobenius norm.

static determinant(matrix)

Computes the determinant of the provided matrix.

Parameters:
  • matrix

  • Matrix3

  • use. (The matrix to) –

Returns:

A float, The value of the determinant of the matrix.

static equals(left, right)

Compares the provided matrices componentwise and return True if they pass an absolute or relative tolerance test, False otherwise.

Parameters:
  • left

  • Matrix3

  • Cartesian. (The first) –

  • rightMatrix3, The second Cartesian.

  • relativeEpsilon

  • float

  • default=0 (The absolute epsilon tolerance to use for equality testing.) –

  • absoluteEpsilon

  • float

  • default=0

Returns:

A boolean, True if they pass an absolute or relative tolerance test, False otherwise.

static equalsEpsilon(left, right, epsilon=0)

Compares the provided matrices componentwise and return True if they pass an absolute or relative tolerance test, False otherwise.

Parameters:
  • left

  • Matrix3

  • Cartesian. (The first) –

  • rightMatrix3, The second Cartesian.

  • epsilon

  • float

  • testing. (The epsilon to use for equality) –

Returns:

A boolean, True if they pass an absolute or relative tolerance test, False otherwise.

static fromArray(array, startingIndex=0, result=None)

Creates a Matrix3 from 9 consecutive elements in an array.

Parameters:
  • arraylist, The array whose 9 consecutive elements correspond to the positions of the matrix. Assumes column-major order.

  • startingIndexint, The offset into the array of the first element, which corresponds to the x component.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter or a new Matrix3 instance if one was not provided.

static fromColumnMajorArray(values, result=None)

Creates a Matrix3 from a column-major order array. The resulting matrix will be in column-major order.

Parameters:
  • valueslist, The column-major order array.

  • startingIndexint, The offset into the array of the first element, which corresponds to the x component.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter or a new Matrix3 instance if one was not provided.

static fromCrossProduct(vector, result=None)

Computes a Matrix3 instance representing the cross product equivalent matrix of a Cartesian3 vector.

Parameters:
  • vectorCartesian3, The vector on the left hand side of the cross product operation.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter or a new Matrix3 instance if one was not provided.

static fromHeadingPitchRoll(headingPitchRoll, result=None)

Computes a 3x3 rotation matrix from the provided headingPitchRoll.

Parameters:
  • headingPitchRolldict, The headingPitchRoll to use.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter or a new Matrix3 instance if one was not provided.

static fromQuaternion(quaternion, result=None)

Computes a 3x3 rotation matrix from the provided quaternion.

Parameters:
  • quaternionQuaternion, The quaternion to use.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter or a new Matrix3 instance if one was not provided.

static fromRotationX(angle, result=None)

Creates a rotation matrix around the x-axis.

Parameters:
  • anglefloat, The angle, in radians, of the rotation. Positive angles are counterclockwise.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter or a new Matrix3 instance if one was not provided.

static fromRotationY(angle, result=None)

Creates a rotation matrix around the y-axis.

Parameters:
  • anglefloat, The angle, in radians, of the rotation. Positive angles are counterclockwise.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter or a new Matrix3 instance if one was not provided.

static fromRotationZ(angle, result=None)

Creates a rotation matrix around the z-axis.

Parameters:
  • anglefloat, The angle, in radians, of the rotation. Positive angles are counterclockwise.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter or a new Matrix3 instance if one was not provided.

static fromRowMajorArray(values, result=None)

Creates a Matrix3 from a row-major order array. The resulting matrix will be in column-major order.

Parameters:
  • valueslist, The row-major order array.

  • startingIndexint, The offset into the array of the first element, which corresponds to the x component.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter or a new Matrix3 instance if one was not provided.

static fromScale(scale, result=None)

Computes a Matrix3 instance representing a non-uniform scale.

Parameters:
  • scaleCartesian3, The x, y, and z scale factors.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter or a new Matrix3 instance if one was not provided.

static fromUniformScale(scale, result=None)

Computes a Matrix3 instance representing a uniform scale.

Parameters:
  • scalefloat, The uniform scale factor.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter or a new Matrix3 instance if one was not provided.

static getColumn(matrix, index, result)

Retrieves a copy of the matrix column at the provided index as a Cartesian3 instance.

Parameters:
  • matrixMatrix3, The matrix to use.

  • indexint, The zero-based index of the column to retrieve.

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter.

static getElementIndex(column, row)

Computes the array index of the element at the provided row and column.

Parameters:
  • rowint, The zero-based index of the row.

  • columnint, The zero-based index of the column.

Returns:

A int, The index of the element at the provided row and column.

static getMaximumScale(matrix)

Computes the maximum scale assuming the matrix is an affine transformation. The maximum scale is the maximum length of the column vectors.

Parameters:

matrixMatrix3, The matrix.

Returns:

A float, The maximum scale.

static getRotation(matrix, result)

Extracts the rotation matrix assuming the matrix is an affine transformation.

Parameters:
  • matrixMatrix3, The matrix.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static getRow(matrix, index, result)

Retrieves a copy of the matrix row at the provided index as a Cartesian3 instance.

Parameters:
  • matrixMatrix3, The matrix to use.

  • indexint, The zero-based index of the row to retrieve.

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter.

static getScale(matrix, result)

Extracts the non-uniform scale assuming the matrix is an affine transformation.

Parameters:
  • matrixMatrix3, The matrix.

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter.

static inverse(matrix, result)

Computes the inverse of the provided matrix.

Parameters:
  • matrix

  • Matrix3

  • invert. (The matrix to) –

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static inverseTranspose(matrix, result)

Computes the inverse transpose of a matrix.

Parameters:
  • matrix

  • Matrix3

  • invert. (The matrix to transpose and) –

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static multiply(left, right, result)

Computes the product of two matrices.

Parameters:
  • leftMatrix3, The first matrix.

  • rightMatrix3, The second matrix.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static multiplyByScalar(matrix, scalar, result)

Computes the product of a matrix and a scalar.

Parameters:
  • matrixMatrix3, The matrix.

  • scalarfloat, The number to multiply by.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static multiplyByScale(matrix, scale, result)

Computes the product of a matrix times a (non-uniform) scale, as if the scale were a scale matrix.

Parameters:
  • matrixMatrix3, The matrix.

  • scaleCartesian3, The non-uniform scale on the right-hand side.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static multiplyByUniformScale(matrix, scale, result)

Computes the product of a matrix times a uniform scale, as if the scale were a scale matrix.

Parameters:
  • matrixMatrix3, The matrix.

  • scalefloat, The uniform scale on the right-hand side.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static multiplyByVector(matrix, cartesian, result)

Computes the product of a matrix and a column vector.

Parameters:
  • matrixMatrix3, The matrix.

  • cartesianCartesian3, The column.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static negate(matrix, result)

Negates the provided matrix.

Parameters:
  • matrix

  • Matrix3

  • negated. (The matrix to be) –

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static offDiagonalFrobeniusNorm(matrix)

Computes the “off-diagonal” Frobenius norm. Assumes matrix is symmetric.

Parameters:
  • matrix

  • Matrix3

  • computed. (The matrix to be) –

Returns:

A float, The Frobenius norm.

packedLength = 9
static setColumn(matrix, index, cartesian, result)

Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian3 instance.

Parameters:
  • matrixMatrix3, The matrix to use.

  • indexint, The zero-based index of the column to retrieve.

  • cartesianCartesian3, The Cartesian whose values will be assigned to the specified column.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static setRotation(matrix, rotation, result)

Sets the rotation assuming the matrix is an affine transformation.

Parameters:
  • matrixMatrix3, The matrix to use.

  • rotationMatrix3, The rotation matrix.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static setRow(matrix, index, cartesian, result)

Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian3 instance.

Parameters:
  • matrixMatrix3, The matrix to use.

  • indexint, The zero-based index of the row to retrieve.

  • cartesianCartesian3, The Cartesian whose values will be assigned to the specified row.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static setScale(matrix, scale, result)

Computes a new matrix that replaces the scale with the provided scale. This assumes the matrix is an affine transformation.

Parameters:
  • matrixMatrix3, The matrix to use.

  • scaleCartesian3, The scale that replaces the scale of the provided matrix.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static setUniformScale(matrix, scale, result)

Computes a new matrix that replaces the scale with the provided uniform scale. This assumes the matrix is an affine transformation.

Parameters:
  • matrixMatrix3, The matrix to use.

  • scalefloat, The uniform scale that replaces the scale of the provided matrix.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static shurDecomposition(matrix, result)

This routine was created based upon Matrix Computations, 3rd ed., by Golub and Van Loan, section 8.4.2 The 2by2 Symmetric Schur Decomposition. The routine takes a matrix, which is assumed to be symmetric, and finds the largest off-diagonal term, and then creates a matrix (result) which can be used to help reduce it

Parameters:
  • matrix

  • Matrix3

  • matrix. (The) –

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static subtract(left, right, result)

Computes the difference of two matrices.

Parameters:
  • leftMatrix3, The first matrix.

  • rightMatrix3, The second matrix.

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

static toArray(matrix, result=None)

Creates an Array from the provided Matrix3 instance. The array will be in column-major order.

Parameters:
  • matrixMatrix3, The matrix to use.

  • resultlist, The Array onto which to store the result.

Returns:

A list, The modified Array parameter or a new Array instance if one was not provided.

static transpose(matrix, result)

Computes the transpose of the provided matrix.

Parameters:
  • matrix

  • Matrix3

  • transpose. (The matrix to be) –

  • resultMatrix3, The object onto which to store the result.

Returns:

A Matrix3, The modified result parameter.

satsim.vecmath.Matrix4 module

class satsim.vecmath.Matrix4.Matrix4(column0Row0=0.0, column1Row0=0.0, column2Row0=0.0, column3Row0=0.0, column0Row1=0.0, column1Row1=0.0, column2Row1=0.0, column3Row1=0.0, column0Row2=0.0, column1Row2=0.0, column2Row2=0.0, column3Row2=0.0, column0Row3=0.0, column1Row3=0.0, column2Row3=0.0, column3Row3=0.0)

Bases: object

A 4x4 matrix, indexable as a column-major order array. Constructor parameters are in row-major order for code readability.

COLUMN0ROW0 = 0
COLUMN0ROW1 = 1
COLUMN0ROW2 = 2
COLUMN0ROW3 = 3
COLUMN1ROW0 = 4
COLUMN1ROW1 = 5
COLUMN1ROW2 = 6
COLUMN1ROW3 = 7
COLUMN2ROW0 = 8
COLUMN2ROW1 = 9
COLUMN2ROW2 = 10
COLUMN2ROW3 = 11
COLUMN3ROW0 = 12
COLUMN3ROW1 = 13
COLUMN3ROW2 = 14
COLUMN3ROW3 = 15
static IDENTITY()

A Matrix4 initialized to the identity matrix.

static ZERO()

A Matrix4 initialized to the zero matrix.

static abs(matrix, result)

Computes a matrix, which contains the absolute (unsigned) values of the provided matrix’s elements.

Parameters:
  • matrix

  • Matrix4

  • elements. (The matrix with signed) –

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static add(left, right, result)

Computes the sum of two matrices.

Parameters:
  • leftMatrix4, The first matrix.

  • rightMatrix4, The second matrix.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static clone(matrix=None, result=None)

Creates a Matrix4 from 16 consecutive elements in an array.

Parameters:
  • arraylist, The array whose 16 consecutive elements correspond to the positions of the matrix. Assumes column-major order.

  • startingIndexint, The offset into the array of the first element, which corresponds to the x component.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static computeInfinitePerspectiveOffCenter(left, right, bottom, top, near, result=None)

Computes a Matrix4 instance representing an infinite off center perspective transformation.

Parameters:
  • leftfloat, The number of meters to the left of the camera that will be in view.

  • rightfloat, The number of meters to the right of the camera that will be in view.

  • bottomfloat, The number of meters below of the camera that will be in view.

  • topfloat, The number of meters above of the camera that will be in view.

  • nearfloat, The distance to the near plane in meters.

  • farfloat, The distance to the far plane in meters.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static computeLookAt(position, target, up, result=None)

Computes look at transform from observer to target.

Parameters:
  • positionCartesian3, The observer position.

  • targetCartesian3, The target position.

  • upCartesian3, The up direction.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static computeOrthographicOffCenter(left, right, bottom, top, near, far, result=None)

Computes a Matrix4 instance representing a perspective transformation matrix.

Parameters:
  • leftfloat, The number of meters to the left of the camera that will be in view.

  • rightfloat, The number of meters to the right of the camera that will be in view.

  • bottomfloat, The number of meters below of the camera that will be in view.

  • topfloat, The number of meters above of the camera that will be in view.

  • nearfloat, The distance to the near plane in meters.

  • farfloat, The distance to the far plane in meters.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static computePerspectiveFieldOfView(fovY, aspectRatio, near, far, result=None)

Computes a Matrix4 instance representing a perspective transformation matrix.

Parameters:
  • fovYfloat, The field of view along the Y axis in radians.

  • aspectRatiofloat, The aspect ratio.

  • nearfloat, The distance to the near plane in meters.

  • farfloat, The distance to the far plane in meters.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static computePerspectiveOffCenter(left, right, bottom, top, near, far, result=None)

Computes a Matrix4 instance representing an off center perspective transformation.

Parameters:
  • leftfloat, The number of meters to the left of the camera that will be in view.

  • rightfloat, The number of meters to the right of the camera that will be in view.

  • bottomfloat, The number of meters below of the camera that will be in view.

  • topfloat, The number of meters above of the camera that will be in view.

  • nearfloat, The distance to the near plane in meters.

  • farfloat, The distance to the far plane in meters.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static computeView(position, direction, up, right, result=None)

Computes a Matrix4 instance that transforms from world space to view space.

Parameters:
  • positionCartesian3, The position of the camera.

  • directionCartesian3, The forward direction.

  • upCartesian3, The up direction.

  • rightCartesian3, The right direction.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static computeViewportTransformation(viewport={}, nearDepthRange=0.0, farDepthRange=1.0, result=None)

Computes a Matrix4 instance that transforms from normalized device coordinates to window coordinates.

Parameters:
  • viewportdict, The viewport’s corners.

  • nearDepthRangefloat, The near plane distance in window coordinates.

  • farDepthRangefloat, The far plane distance in window coordinates.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static equalsEpsilon(left, right, epsilon=0)

Compares the provided matrices componentwise and return True if they pass an absolute or relative tolerance test, False otherwise.

Parameters:
  • left

  • Matrix4

  • Cartesian. (The first) –

  • rightMatrix4, The second Cartesian.

  • epsilon

  • float

  • testing. (The epsilon to use for equality) –

Returns:

A boolean, True if they pass an absolute or relative tolerance test, False otherwise.

static fromArray(array, startingIndex=0, result=None)

Creates a Matrix4 from 16 consecutive elements in an array.

Parameters:
  • arraylist, The array whose 16 consecutive elements correspond to the positions of the matrix. Assumes column-major order.

  • startingIndexint, The offset into the array of the first element, which corresponds to the x component.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static fromCamera(camera, result=None)

Computes a Matrix4 instance from a Camera.

Parameters:
  • cameradict, The camera to use.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static fromColumnMajorArray(values, result=None)

Creates a Matrix4 from a column-major order array. The resulting matrix will be in column-major order.

Parameters:
  • valueslist, The column-major order array.

  • startingIndexint, The offset into the array of the first element, which corresponds to the x component.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static fromRotation(rotation, result=None)

Creates a rotation matrix.

Parameters:
  • rotationMatrix3, The rotation matrix.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static fromRotationTranslation(rotation, translation=<satsim.vecmath.Cartesian3.Cartesian3 object>, result=None)

Computes a Matrix4 instance from a Matrix3 representing the rotation and a Cartesian3 representing the translation.

Parameters:
  • rotationMatrix3, The upper left portion of the matrix representing the rotation.

  • translationCartesian3, The upper right portion of the matrix representing the translation.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static fromRowMajorArray(values, result=None)

Creates a Matrix4 from a row-major order array. The resulting matrix will be in column-major order.

Parameters:
  • valueslist, The row-major order array.

  • startingIndexint, The offset into the array of the first element, which corresponds to the x component.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static fromScale(scale, result=None)

Computes a Matrix4 instance representing a non-uniform scale.

Parameters:
  • scaleCartesian3, The x, y, and z scale factors.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static fromTranslation(translation, result=None)

Creates a Matrix4 instance from a Cartesian3 representing the translation.

Parameters:
  • translationCartesian3, The translation transformation.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static fromTranslationQuaternionRotationScale(translation, rotation, scale, result=None)

Computes a Matrix4 instance from a translation, rotation, and scale (TRS) representation with the rotation represented as a quaternion.

Parameters:
  • translationCartesian3, The translation transformation.

  • rotationQuaternion, The rotation transformation.

  • scaleCartesian3, The non-uniform scale transformation.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static fromTranslationRotationScale(translationRotationScale, result=None)

Creates a Matrix4 instance from a dict.

Parameters:
  • translationRotationScaledict, The translation, rotation, and scale.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static fromUniformScale(scale, result=None)

Computes a Matrix4 instance representing a uniform scale.

Parameters:
  • scalefloat, The uniform scale factor.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter or a new Matrix4 instance if one was not provided.

static getColumn(matrix, index, result)

Retrieves a copy of the matrix column at the provided index as a Cartesian3 instance.

Parameters:
  • matrixMatrix4, The matrix to use.

  • indexint, The zero-based index of the column to retrieve.

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter.

static getElementIndex(column, row)

Computes the array index of the element at the provided row and column.

Parameters:
  • rowint, The zero-based index of the row.

  • columnint, The zero-based index of the column.

Returns:

A int, The index of the element at the provided row and column.

static getMatrix3(matrix, result)

Gets the upper left 3x3 matrix of the provided matrix.

Parameters:
  • matrix

  • Matrix4

  • use. (The matrix to) –

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static getMaximumScale(matrix)

Computes the maximum scale assuming the matrix is an affine transformation. The maximum scale is the maximum length of the column vectors.

Parameters:

matrixMatrix4, The matrix.

Returns:

A float, The maximum scale.

static getRotation(matrix, result)

Extracts the rotation matrix assuming the matrix is an affine transformation.

Parameters:
  • matrixMatrix4, The matrix.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static getRow(matrix, index, result)

Retrieves a copy of the matrix row at the provided index as a Cartesian3 instance.

Parameters:
  • matrixMatrix4, The matrix to use.

  • indexint, The zero-based index of the row to retrieve.

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The modified result parameter.

static getScale(matrix, result)

Extracts the non-uniform scale assuming the matrix is an affine transformation.

Parameters:
  • matrixMatrix4, The matrix.

  • resultCartesian3, The object onto which to store the result.

Returns:

A Cartesian3, The modified result parameter.

static getTranslation(matrix, result)

Gets the translation portion of the provided matrix, assuming the matrix is an affine transformation matrix.

Parameters:
  • matrix

  • Matrix4

  • use. (The matrix to) –

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static inverse(matrix, result)

Computes the inverse of the provided matrix using Cramers Rule. If the determinant is zero, the matrix can not be inverted, and an exception is thrown. If the matrix is a proper rigid transformation, it is more efficient to invert it with {@link Matrix4.inverseTransformation}.

Parameters:
  • matrix

  • Matrix4

  • invert. (The matrix to) –

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static inverseTransformation(matrix, result)

Computes the inverse of the provided matrix assuming it is a proper rigid matrix, where the upper left 3x3 elements are a rotation matrix, and the upper three elements in the fourth column are the translation. The bottom row is assumed to be [0, 0, 0, 1]. The matrix is not verified to be in the proper form. This method is faster than computing the inverse for a general 4x4 matrix using inverse.

Parameters:
  • matrix

  • Matrix4

  • invert. (The matrix to) –

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static inverseTranspose(matrix, result)

Computes the inverse transpose of a matrix.

Parameters:
  • matrix

  • Matrix4

  • invert. (The matrix to transpose and) –

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

m

Constructor.

Parameters:
  • column0Row0float, The value for column 0, row 0.

  • column1Row0float, The value for column 1, row 0.

  • column2Row0float, The value for column 2, row 0.

  • column3Row0float, The value for column 3, row 0.

  • column0Row1float, The value for column 0, row 1.

  • column1Row1float, The value for column 1, row 1.

  • column2Row1float, The value for column 2, row 1.

  • column3Row1float, The value for column 3, row 1.

  • column0Row2float, The value for column 0, row 2.

  • column1Row2float, The value for column 1, row 2.

  • column2Row2float, The value for column 2, row 2.

  • column3Row2float, The value for column 3, row 2.

  • column0Row3float, The value for column 0, row 3.

  • column1Row3float, The value for column 1, row 3.

  • column2Row3float, The value for column 2, row 3.

  • column3Row3float, The value for column 3, row 3.

static multiply(left, right, result)

Computes the product of two matrices.

Parameters:
  • leftMatrix4, The first matrix.

  • rightMatrix4, The second matrix.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static multiplyByMatrix3(matrix, rotation, result)

Multiplies a transformation matrix by a 3x3 rotation matrix. This is an optimization with less allocations and arithmetic operations than fromRotationTranslation.

Parameters:
  • matrixMatrix4, The matrix on the left-hand side.

  • rotationMatrix4, The 3x3 rotation matrix on the right-hand side.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static multiplyByPoint(matrix, cartesian, result)
Computes the product of a matrix and a Cartesian3. This is equivalent to calling multiplyByVector

with a Cartesian4 with a w component of 1, but returns a Cartesian3 instead of a Cartesian4.

Parameters:
  • matrixMatrix4, The matrix.

  • cartesianCartesian4, The point.

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The modified result parameter.

static multiplyByPointAsVector(matrix, cartesian, result)

Computes the product of a matrix and a Cartesian3.

Parameters:
  • matrixMatrix4, The matrix.

  • cartesianCartesian4, The point.

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The modified result parameter.

static multiplyByScalar(matrix, scalar, result)

Computes the product of a matrix and a scalar.

Parameters:
  • matrixMatrix4, The matrix.

  • scalarfloat, The number to multiply by.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static multiplyByScale(matrix, scale, result)

Multiplies a transformation matrix by an implicit non-uniform scale matrix. This is an optimization with less allocations and arithmetic operations than fromRotationTranslation.

Parameters:
  • matrixMatrix4, The matrix on the left-hand side.

  • scaleCartesian3, The non-uniform scale on the right-hand side.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static multiplyByTranslation(matrix, translation, result)

Multiplies a transformation matrix by an implicit translation matrix defined by a Cartesian3. This is an optimization with less allocations and arithmetic operations than fromRotationTranslation.

Parameters:
  • matrixMatrix4, The matrix on the left-hand side.

  • translationMatrix4, The translation on the right-hand side.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static multiplyByUniformScale(matrix, scale, result)

Computes the product of a matrix times a uniform scale, as if the scale were a scale matrix.

Parameters:
  • matrixMatrix4, The matrix on the left-hand side.

  • scalefloat, The uniform scale on the right-hand side.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static multiplyByVector(matrix, cartesian, result)

Computes the product of a matrix and a column vector.

Parameters:
  • matrixMatrix4, The matrix.

  • cartesianCartesian4, The vector.

  • resultCartesian4, The object onto which to store the result.

Returns:

A Cartesian4, The modified result parameter.

static multiplyTransformation(left, right, result)

Computes the product of two matrices assuming the matrices are affine transformation matrices, where the upper left 3x3 elements are any matrix, and the upper three elements in the fourth column are the translation. The bottom row is assumed to be [0, 0, 0, 1]. The matrix is not verified to be in the proper form. This method is faster than computing the product for general 4x4 matrices.

Parameters:
  • leftMatrix4, The first matrix.

  • rightMatrix4, The second matrix.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static negate(matrix, result)

Negates the provided matrix.

Parameters:
  • matrix

  • Matrix4

  • negated. (The matrix to be) –

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

packedLength = 16
static setColumn(matrix, index, cartesian, result)

Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian3 instance.

Parameters:
  • matrixMatrix4, The matrix to use.

  • indexint, The zero-based index of the column to retrieve.

  • cartesianCartesian3, The Cartesian whose values will be assigned to the specified column.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static setRotation(matrix, rotation, result)

Sets the rotation assuming the matrix is an affine transformation.

Parameters:
  • matrixMatrix4, The matrix to use.

  • rotationMatrix3, The rotation matrix.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static setRow(matrix, index, cartesian, result)

Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian3 instance.

Parameters:
  • matrixMatrix4, The matrix to use.

  • indexint, The zero-based index of the row to retrieve.

  • cartesianCartesian3, The Cartesian whose values will be assigned to the specified row.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static setScale(matrix, scale, result)

Computes a new matrix that replaces the scale with the provided scale. This assumes the matrix is an affine transformation.

Parameters:
  • matrixMatrix4, The matrix to use.

  • scaleCartesian3, The scale that replaces the scale of the provided matrix.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static setTranslation(matrix, translation, result)
Computes a new matrix that replaces the translation in the rightmost column of the provided

matrix with the provided translation. This assumes the matrix is an affine transformation.

Parameters:
  • matrixMatrix4, The matrix to use.

  • translationCartesian3, The translation that replaces the translation of the provided matrix.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static setUniformScale(matrix, scale, result)

Computes a new matrix that replaces the scale with the provided uniform scale. This assumes the matrix is an affine transformation.

Parameters:
  • matrixMatrix4, The matrix to use.

  • scalefloat, The uniform scale that replaces the scale of the provided matrix.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static subtract(left, right, result)

Computes the difference of two matrices.

Parameters:
  • leftMatrix4, The first matrix.

  • rightMatrix4, The second matrix.

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

static toArray(matrix, result=None)

Creates an Array from the provided Matrix4 instance. The array will be in column-major order.

Parameters:
  • matrixMatrix4, The matrix to use.

  • resultlist, The Array onto which to store the result.

Returns:

A list, The modified Array parameter or a new Array instance if one was not provided.

static transpose(matrix, result)

Computes the transpose of the provided matrix.

Parameters:
  • matrix

  • Matrix4

  • transpose. (The matrix to be) –

  • resultMatrix4, The object onto which to store the result.

Returns:

A Matrix4, The modified result parameter.

satsim.vecmath.Quaternion module

class satsim.vecmath.Quaternion.Quaternion(x=0.0, y=0.0, z=0.0, w=0.0)

Bases: object

A 4D Cartesian point.

static add(left, right, result)

Computes the component wise sum of two Quaternions.

Parameters:
  • left

  • Quaternion

  • Cartesian. (The second) –

  • right

  • Quaternion

  • Cartesian.

  • resultQuaternion, The object onto which to store the result.

Returns:

A float, The modified result parameter.

static clone(quaternion=None, result=None)

Duplicates a Quaternion instance.

Parameters:
  • quaternionQuaternion, The quaternion to duplicate.

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter or a new Quaternion instance if one was not provided.

static computeAngle(quaternion)

Computes the angle of rotation of the provided quaternion.

Parameters:
  • quaternion

  • Quaternion

  • use. (The quaternion to) –

Returns:

A float, The angle of rotation.

static computeAxis(quaternion, result)

Computes the axis of rotation of the provided quaternion.

Parameters:
  • quaternion

  • Quaternion

  • use. (The quaternion to) –

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static computeInnerQuadrangle(q0, q1, q2, result)

Computes an inner quadrangle point.

Parameters:
  • q0

  • Quaternion

  • quaternion. (The third) –

  • q1

  • Quaternion

  • quaternion.

  • q2

  • Quaternion

  • quaternion.

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static conjugate(quaternion, result)

Computes the conjugate of the provided quaternion.

Parameters:
  • quaternionQuaternion, The quaternion to conjugate.

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static divideByScalar(quaternion, scalar, result)

Divides the provided Cartesian componentwise by the provided scalar.

Parameters:
  • quaternion

  • Quaternion

  • divided. (The Cartesian to be) –

  • scalar

  • float

  • by. (The scalar to divide) –

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static dot(left, right)

Computes the dot (scalar) product of two Quaternions.

Parameters:
  • left

  • Quaternion

  • Cartesian. (The second) –

  • right

  • Quaternion

  • Cartesian.

Returns:

A float, The dot product.

static equals(left, right)

Compares the provided Quaternions componentwise and return True if equal, False otherwise

Parameters:
  • left

  • Quaternion

  • Cartesian. (The first) –

  • rightQuaternion, The second Cartesian.

Returns:

A boolean, True if equal, False otherwise.

static equalsEpsilon(left, right, epsilon=0)

Compares the provided Quaternions componentwise and return True if they pass an absolute or relative tolerance test, False otherwise.

Parameters:
  • left

  • Quaternion

  • Cartesian. (The first) –

  • rightQuaternion, The second Cartesian.

  • relativeEpsilon

  • float

  • default=0 (The absolute epsilon tolerance to use for equality testing.) –

  • absoluteEpsilon

  • float

  • default=0

Returns:

A boolean, True if they pass an absolute or relative tolerance test, False otherwise.

static exp(cartesian, result)

The exponential quaternion function.

Parameters:
  • cartesian

  • Cartesian3

  • cartesian. (The) –

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static fastSlerp(start, end, t, result)

Computes the spherical linear interpolation or extrapolation at t using the provided quaternions. Note: This implementation is faster but is only accurate to 10e-6.

Parameters:
  • start

  • Quaternion

  • 0.0. (The value corresponding to t at) –

  • end

  • Quaternion

  • 1.0. (The value corresponding to t at) –

  • t

  • float

  • interpolate. (The point along t at which to) –

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static fastSquad(q0, q1, s0, s1, t, result)

Computes the spherical quadrangle interpolation between quaternions. Note: This implementation is faster but is only accurate to 10e-6.

Parameters:
  • q0

  • Quaternion

  • quaternion. (The second) –

  • q1

  • Quaternion

  • quaternion.

  • s0

  • Quaternion

  • quadrangle. (The first inner) –

  • s1

  • Quaternion

  • quadrangle.

  • t

  • float

  • interpolate. (The point along t at which to) –

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static fromAxisAngle(axis, angle, result=None)

Computes a quaternion representing a rotation around an axis.

Parameters:
  • axisCartesian3, The axis of rotation.

  • anglefloat, The angle in radians to rotate around the axis.

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter or a new Quaternion instance if one was not provide

static fromHeadingPitchRoll(headingPitchRoll, result=None)

Computes a rotation from the given heading, pitch and roll angles. Heading is the rotation about the negative z axis. Pitch is the rotation about the negative y axis. Roll is the rotation about the positive x axis.

Parameters:
  • headingPitchRolldict, The rotation expressed as a heading, pitch and roll.

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter or a new Quaternion instance if one was not provide

static fromRotationMatrix(matrix, result=None)

Computes a Quaternion from the provided Matrix3 instance.

Parameters:
  • axisCartesian3, The axis of rotation.

  • anglefloat, The angle in radians to rotate around the axis.

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter or a new Quaternion instance if one was not provide

static inverse(quaternion, result)

Computes the inverse of the provided quaternion.

Parameters:
  • quaternion

  • Quaternion

  • invert. (The quaternion to) –

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static lerp(start, end, t, result)

Computes the linear interpolation or extrapolation at t using the provided cartesians.

Parameters:
  • start

  • Quaternion

  • 0.0. (The value corresponding to t at) –

  • end

  • Quaternion

  • 1.0. (The value corresponding to t at) –

  • t

  • float

  • interpolate. (The point along t at which to) –

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static log(quaternion, result)

The logarithmic quaternion function.

Parameters:
  • quaternion

  • Quaternion

  • quaternion. (The unit) –

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static magnitude(quaternion)

Computes the provided Cartesian’s magnitude (length).

Parameters:

quaternionQuaternion, he Cartesian instance whose magnitude is to be computed.

Returns:

A float, The magnitude.

static magnitudeSquared(quaternion)

Computes the provided Cartesian’s squared magnitude.

Parameters:

quaternionQuaternion, he Cartesian instance whose squared magnitude is to be computed.

Returns:

A float, The squared magnitude.

static multiply(left, right, result)

Computes the product of two quaternions.

Parameters:
  • left

  • Quaternion

  • quaternion. (right The second) –

  • right

  • float

  • quaternion.

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static multiplyByScalar(quaternion, scalar, result)

Multiplies the provided Cartesian componentwise by the provided scalar.

Parameters:
  • quaternion

  • Quaternion

  • scaled. (The Cartesian to be) –

  • scalar

  • float

  • with. (The scalar to multiply) –

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static negate(quaternion, result)

Negates the provided Cartesian.

Parameters:
  • quaternion

  • Quaternion

  • negated. (The Cartesian to be) –

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static normalize(quaternion, result)

Computes the normalized form of the supplied Cartesian.

Parameters:
  • quaternion

  • Quaternion

  • normalized. (The Cartesian to be) –

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static slerp(start, end, t, result)

Computes the spherical linear interpolation or extrapolation at t using the provided quaternions.

Parameters:
  • start

  • Quaternion

  • 0.0. (The value corresponding to t at) –

  • end

  • Quaternion

  • 1.0. (The value corresponding to t at) –

  • t

  • float

  • interpolate. (The point along t at which to) –

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static squad(q0, q1, s0, s1, t, result)

Computes the spherical quadrangle interpolation between quaternions.

Parameters:
  • q0

  • Quaternion

  • quaternion. (The second) –

  • q1

  • Quaternion

  • quaternion.

  • s0

  • Quaternion

  • quadrangle. (The first inner) –

  • s1

  • Quaternion

  • quadrangle.

  • t

  • float

  • interpolate. (The point along t at which to) –

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static subtract(left, right, result)

Computes the component wise difference of two Quaternions.

Parameters:
  • left

  • Quaternion

  • Cartesian. (The second) –

  • right

  • Quaternion

  • Cartesian.

  • resultQuaternion, The object onto which to store the result.

Returns:

A Quaternion, The modified result parameter.

static toHeadingPitchRoll(quaternion, result={})

Computes the heading, pitch and roll from a quaternion.

Parameters:
  • quaternionQuaternion, The quaternion from which to retrieve heading, pitch, and roll, all expressed in radians.

  • resultdict, The object onto which to store the result.

Returns:

A dict, The result as a dict with heading, pitch, and roll.