Documentation
¶
Index ¶
- type Acceleration
- type Event
- type Mass
- type Matrix3x3
- func (m Matrix3x3) Add(other Matrix3x3) Matrix3x3
- func (m Matrix3x3) Determinant() float64
- func (m Matrix3x3) Inverse() *Matrix3x3
- func (m *Matrix3x3) MultiplyMatrix(other *Matrix3x3) *Matrix3x3
- func (m Matrix3x3) MultiplyScalar(s float64) Matrix3x3
- func (m *Matrix3x3) MultiplyVector(v *Vector3) *Vector3
- func (m Matrix3x3) Subtract(other Matrix3x3) Matrix3x3
- func (m *Matrix3x3) Transpose() *Matrix3x3
- type Orientation
- type Position
- type Quaternion
- func (q *Quaternion) Add(q2 *Quaternion) *Quaternion
- func (q *Quaternion) Conjugate() *Quaternion
- func (q *Quaternion) Integrate(omega Vector3, dt float64) *Quaternion
- func (q *Quaternion) Inverse() *Quaternion
- func (q *Quaternion) IsIdentity() bool
- func (q *Quaternion) Magnitude() float64
- func (q *Quaternion) Multiply(q2 *Quaternion) *Quaternion
- func (q *Quaternion) Normalize() *Quaternion
- func (q *Quaternion) RotateVector(v *Vector3) *Vector3
- func (q *Quaternion) Scale(scalar float64) *Quaternion
- func (q *Quaternion) Subtract(q2 *Quaternion) *Quaternion
- type Vector3
- func (v Vector3) Add(other Vector3) Vector3
- func (v Vector3) DivideScalar(scalar float64) Vector3
- func (v Vector3) Dot(other Vector3) float64
- func (v Vector3) Magnitude() float64
- func (v Vector3) MultiplyScalar(scalar float64) Vector3
- func (v Vector3) Normalize() Vector3
- func (v Vector3) Round(precision int) Vector3
- func (v Vector3) String() string
- func (v Vector3) Subtract(other Vector3) Vector3
- type Velocity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Acceleration ¶
type Acceleration struct {
ecs.BasicEntity
Vec Vector3
}
Acceleration represents a 3D acceleration as a vector
type Matrix3x3 ¶ added in v0.8.0
type Matrix3x3 struct {
M11, M12, M13 float64 // Row 1
M21, M22, M23 float64 // Row 2
M31, M32, M33 float64 // Row 3
}
Matrix3x3 represents a 3x3 matrix. Components are row-major: M11, M12, M13 are the first row.
func IdentityMatrix ¶ added in v0.8.0
func IdentityMatrix() *Matrix3x3
IdentityMatrix returns an identity matrix.
func IdentityMatrix3x3 ¶ added in v0.8.0
func IdentityMatrix3x3() Matrix3x3
IdentityMatrix3x3 returns an identity matrix.
func NewMatrix3x3 ¶ added in v0.8.0
NewMatrix3x3 creates a new matrix from a slice of 9 elements (row-major). Returns nil if the elements slice does not contain exactly 9 values.
func RotationMatrixFromQuaternion ¶ added in v0.8.0
func RotationMatrixFromQuaternion(q *Quaternion) *Matrix3x3
RotationMatrixFromQuaternion converts a Quaternion to a 3x3 rotation matrix.
func TransformInertiaBodyToWorld ¶ added in v0.8.0
func TransformInertiaBodyToWorld(inertiaBody *Matrix3x3, rotationMatrixBodyToWorld *Matrix3x3) *Matrix3x3
TransformInertiaBodyToWorld transforms an inertia tensor from body frame to world frame. I_world = R * I_body * R_transpose where R is the rotation matrix from body to world.
func (Matrix3x3) Determinant ¶ added in v0.8.0
Determinant calculates the determinant of the matrix.
func (Matrix3x3) Inverse ¶ added in v0.8.0
Inverse calculates the inverse of the matrix. Returns nil if the matrix is singular (determinant is zero or very close to zero).
func (*Matrix3x3) MultiplyMatrix ¶ added in v0.8.0
MultiplyMatrix multiplies this matrix by another matrix 'other' (M * other).
func (Matrix3x3) MultiplyScalar ¶ added in v0.8.0
MultiplyScalar returns the matrix scaled by a scalar.
func (*Matrix3x3) MultiplyVector ¶ added in v0.8.0
MultiplyVector multiplies the matrix by a column vector v and returns the resulting vector. result = M * v
type Orientation ¶
type Orientation struct {
ecs.BasicEntity
Quat Quaternion
}
Orientation represents a 3D orientation
type Position ¶
type Position struct {
ecs.BasicEntity
Vec Vector3
}
Position represents a 3D position
type Quaternion ¶
type Quaternion struct {
X, Y, Z, W float64
}
Quaternion represents a 3D quaternion
func IdentityQuaternion ¶
func IdentityQuaternion() *Quaternion
IdentityQuaternion returns the identity quaternion
func NewQuaternion ¶
func NewQuaternion(x, y, z, w float64) *Quaternion
NewQuaternion creates a new Quaternion
func (*Quaternion) Add ¶
func (q *Quaternion) Add(q2 *Quaternion) *Quaternion
Add adds two quaternions together
func (*Quaternion) Conjugate ¶
func (q *Quaternion) Conjugate() *Quaternion
Conjugate returns the conjugate of the quaternion
func (*Quaternion) Integrate ¶
func (q *Quaternion) Integrate(omega Vector3, dt float64) *Quaternion
Integrate increments q by the angular velocity (radians/sec) over dt
func (*Quaternion) Inverse ¶ added in v0.8.0
func (q *Quaternion) Inverse() *Quaternion
Inverse returns the inverse of the quaternion. For a unit quaternion (which orientation quaternions should be after normalization), the inverse is its conjugate.
func (*Quaternion) IsIdentity ¶
func (q *Quaternion) IsIdentity() bool
IsIdentity checks if the quaternion is the identity quaternion
func (*Quaternion) Magnitude ¶
func (q *Quaternion) Magnitude() float64
Magnitude returns the sum of squares of the quaternion's components
func (*Quaternion) Multiply ¶
func (q *Quaternion) Multiply(q2 *Quaternion) *Quaternion
Multiply multiplies two quaternions together
func (*Quaternion) Normalize ¶
func (q *Quaternion) Normalize() *Quaternion
Normalize normalizes a quaternion
func (*Quaternion) RotateVector ¶
func (q *Quaternion) RotateVector(v *Vector3) *Vector3
RotateVector rotates a vector v by the quaternion q. Ensures q is normalized. Returns original v if q or v is invalid, or if q normalizes to identity.
func (*Quaternion) Scale ¶
func (q *Quaternion) Scale(scalar float64) *Quaternion
Scale scales a quaternion by a scalar
func (*Quaternion) Subtract ¶
func (q *Quaternion) Subtract(q2 *Quaternion) *Quaternion
Subtract subtracts one quaternion from another
type Vector3 ¶
type Vector3 struct {
X, Y, Z float64
}
Vector3 represents a 3D vector
func (Vector3) DivideScalar ¶
DivideScalar returns the vector divided by a scalar INFO: Ensure the scalar is not zero to avoid division by zero.
func (Vector3) Magnitude ¶
Magnitude returns the length of the vector INFO: Calculating the magnitude as the Euclidean norm.
func (Vector3) MultiplyScalar ¶
MultiplyScalar returns the vector multiplied by a scalar INFO: Scaling the vector components by the given scalar.
func (Vector3) Normalize ¶
Normalize returns the unit vector in the same direction as v. Returns a zero vector if the magnitude is zero, near-zero, NaN, or Inf.
func (Vector3) Round ¶
Round returns the vector with each component rounded to the given precision INFO: Rounding the vector components to the supplied precision.
type Velocity ¶
type Velocity struct {
ecs.BasicEntity
Vec Vector3
}
Velocity represents a 3D velocity