types

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2025 License: GPL-3.0 Imports: 3 Imported by: 0

README

pkg/types

This package defines the core types used throughout the launchrail application.

Responsibility

  • Define the core types used throughout the launchrail application.
  • Provide a consistent and well-defined type system.

Scope

  • Include all necessary types for the application.
  • Support different data types, such as integers, floats, and strings.

Gotchas

  • Ensuring type safety throughout the application.
  • Handling changes to the type system.

Test Suite Overview

The test suite includes unit tests for the core types, including:

  • Validating the type definitions.
  • Ensuring type safety.

Documentation

Index

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 Mass

type Mass struct {
	ecs.BasicEntity
	Value float64
}

Mass represents a mass value

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) 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) Add

func (v Vector3) Add(other Vector3) Vector3

Add returns the sum of two vectors INFO: Adding two vectors component-wise.

func (Vector3) DivideScalar

func (v Vector3) DivideScalar(scalar float64) Vector3

DivideScalar returns the vector divided by a scalar INFO: Ensure the scalar is not zero to avoid division by zero.

func (Vector3) Magnitude

func (v Vector3) Magnitude() float64

Magnitude returns the length of the vector INFO: Calculating the magnitude as the Euclidean norm.

func (Vector3) MultiplyScalar

func (v Vector3) MultiplyScalar(scalar float64) Vector3

MultiplyScalar returns the vector multiplied by a scalar INFO: Scaling the vector components by the given scalar.

func (Vector3) Normalize

func (v Vector3) Normalize() Vector3

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

func (v Vector3) Round(precision int) Vector3

Round returns the vector with each component rounded to the given precision INFO: Rounding the vector components to the supplied precision.

func (Vector3) String

func (v Vector3) String() string

String returns a string representation of the vector INFO: Format the vector components to two decimal places for readability.

func (Vector3) Subtract

func (v Vector3) Subtract(other Vector3) Vector3

Subtract returns the difference of two vectors INFO: Subtracting other vector from this vector component-wise.

type Velocity

type Velocity struct {
	ecs.BasicEntity
	Vec Vector3
}

Velocity represents a 3D velocity

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL