Vector Math Object

From FusionWiki

Jump to: navigation, search
Vector Math Object
General Information
Author: Justin Aquadro
Release Date: 2010
Status: Released
Last updated: Unknown
Version: 1.0
Build:

249

Developer-only: No
Website: Not available
Download: Direct
Runtime Versions
HWA: Yes
Flash: No
Java: No
Java Mobile: No
Vitalize!: No
Unicode: No


The Vector Math Object supports an assortment of operations on vectors and transpose-vectors of length 2, 3, and 4, and on square matrices of size 3 and 4.

Each object can store an unlimited number of vectors, transpose-vectors, and matrices, each identified by a unique string. Each operation will accept one or more source vectors/matrices, and return the result into a separate result vector/matrix (which can be the same as one of the sources). Several predefined vectors and matrices are available such as unit vectors and the zero and identity matrices.

Contents

Vector Operations

Vector Definition

  • Set Vector from Values
  • Set Vector from Vector
  • Set Vector element

Vector Math

  • Add Vector (V1 = V2 + V3)
  • Add Constant (V1 = V2 + C1)
  • Subtract Vector (V1 = V2 - V3)
  • Subtract Constant (V1 = V2 - C1)
  • Scale (V1 = V2 * C1)
  • Scale-Add (V1 = V2 * C1 + C2)
  • Negate (V1 = 0 - V2)
  • Absolute Value (For e in V1, V2[] = |e|)
  • Clamp Values (For e in V1, V2[] = max(C1, min(C2, e)))
  • Clamp Maximum Values (For e in V1, V2[] = min(C1, e))
  • Clamp Minimum Values (For e in V1, V2[] = max(C1, e))
  • Cross Product (V1 = V2 ⨯ V3)
  • Normalize (For e in V1, V2[] = e / max(V1))
  • Transpose (V1T = V2T)

Vector Expressions

  • Dot Product (expr = V1 · V2)
  • Angle (expr = acos(V1 · V2 / |V1||V2|))
  • Length (expr = |V1|)
  • Length Squared (expr = |V1|2)
  • Multiply Transpose-Vector and Vector (expr = V1T * V2)

Matrix Operations

Matrix Definition

  • Set Matrix from Vectors
  • Set Matrix from Matrix
  • Set Matrix Row from Values
  • Set Matrix Row from Vector
  • Set Matrix Column from Values
  • Set Matrix Column from Vector
  • Set Matrix Element

Matrix Math

  • Add Matrix (M1 = M2 + M3)
  • Add Constant (M1 = M2 + C1)
  • Subtract Matrix (M1 = M2 - M3)
  • Subtract Constant (M1 = M2 - C1)
  • Multiply Matrix (M1 = M2 * M3)
  • Multiply Constant (M1 = M2 * C1)
  • Multiply Matrix and Vector (M1 = M2 * V1)
  • Multiply Transpose-Vector and Matrix (M1 = V1T * M2)
  • Negate (M1 = 0 - M2)
  • Invert (M1 = M2-1)
  • Transpose (M1 = M2T)
  • 3D Operations on 4x4 Matrices
    • Rotate
    • Rotate on X-Axis
    • Rotate on Y-Axis
    • Rotate on Z-Axis
    • Scale
    • Translate

Matrix Expressions

  • Determinant (expr = det(M1))

Usage

The following usage shows part of the Forward Kinematics example, where matrix operations are used to propagate translations and rotations of connected links, so that each link in the chain is affected by the translation and rotation of all the links before it. Position values are then read from the matrices TransG0, TransG1, etc. to update the positions of corresponding links.

1
  • Always
  •  : Set Matrix "TransG0" = M4_Identity$(" ")

     : Translate Matrix: "TransG0" = "TransG0" translated by (256, 200, 0)

2
  • Always
  •  : Set Matrix "TransG1" = M4_Identity$(" ")

     : Multiply Matrix: Set Matrix "TransG1" = "TransG0" * "TransG1"

     : Rotate Matrix: Set Matrix "TransG1" = "TransG1" rotated Global Value A degrees on Z-Axis

3
  • Always
  •  : Set matrix "TransG2" = M4_Identity$(" ")

     : Multiply Matrix: Set Matrix "TransG2" = "TransG1" * "TransG2"

     : Translate Matrix: "TransG2" = "TransG2" translated by (0, 110, 0)

     : Rotate Matrix: Set Matrix "TransG2" = "TransG2" rotated Global Value B degrees on Z-Axis

Personal tools