CommonTypesMath
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RicardoSantos

//@version=5

// @description Provides a common library source for common types of useful mathematical structures.
// Includes: `complex, Vector2, Vector3, Vector4, Quaternion, Segment2, Segment3, Pole, Plane, M32, M44`
library("CommonTypesMath")

//#region ~~~ Mathematical Structure Types interface:

// @type Representation of a Complex Number, a complex number `z` is a number in the form `z = x + yi`, 
//			were `x` and `y` are real numbers and i is the imaginary unit, with property `i2 = -1`.
// @field re Real part of the complex number.
// @field im Imaginary part of the complex number.
export type complex
	float re
	float im

// @type Representation of a two dimentional vector with components `(x:float,y:float)`.
// @field x Coordinate `x` of the vector.
// @field y Coordinate `y` of the vector.
export type Vector2
	float x
	float y

// @type Representation of a three dimentional vector with components `(x:float,y:float,z:float)`.
// @field x Coordinate `x` of the vector.
// @field y Coordinate `y` of the vector.
// @field z Coordinate `z` of the vector.
export type Vector3
	float x
	float y
	float z

// @type Representation of a four dimentional vector with components `(x:float,y:float,z:float,w:float)`.
// @field x Coordinate `x` of the vector.
// @field y Coordinate `y` of the vector.
// @field z Coordinate `z` of the vector.
// @field w Coordinate `w` of the vector.
export type Vector4
	float x
	float y
	float z
	float w

// @type Representation of a four dimentional vector with components `(x:float,y:float,z:float,w:float)`.
// @field x Coordinate `x` of the vector.
// @field y Coordinate `y` of the vector.
// @field z Coordinate `z` of the vector.
// @field w Coordinate `w` of the vector, specifies the rotation component.
export type Quaternion
	float x
	float y
	float z
	float w

//@type Representation of a line in two dimentional space.
// @field origin Origin coordinates.
// @field target Target coordinates.
export type Segment2
	Vector2 origin
	Vector2 target

//@type Representation of a line in three dimentional space.
// @field origin Origin coordinates.
// @field target Target coordinates.
export type Segment3
	Vector3 origin
	Vector3 target

// @type Representation of polar coordinates `(radius:float,angle:float)`.
// @field radius Radius of the pole.
// @field angle  Angle in radians of the pole.
export type Pole
	float radius
	float angle

// @type Representation of a 3D plane.
// @field normal   Normal vector of the plane.
// @field distance Distance of the plane along its normal from the origin.
export type Plane
	Vector3 normal
	float   distance

// @type Representation of a 3x2 matrix.
// @field m11 First element of the first row.
// @field m12 Second element of the first row.
// @field m21 First element of the second row.
// @field m22 Second element of the second row.
// @field m31 First element of the third row.
// @field m32 Second element of the third row.
export type M32
	float m11
	float m12
	float m21
	float m22
	float m31
	float m32

// @type Representation of a 4x4 matrix.
// @field m11 First element of the first row.
// @field m12 Second element of the first row.
// @field m13 Third element of the first row.
// @field m14 fourth element of the first row.
// @field m21 First element of the second row.
// @field m22 Second element of the second row.
// @field m23 Third element of the second row.
// @field m24 fourth element of the second row.
// @field m31 First element of the third row.
// @field m32 Second element of the third row.
// @field m33 Third element of the third row.
// @field m34 fourth element of the third row.
// @field m41 First element of the fourth row.
// @field m42 Second element of the fourth row.
// @field m43 Third element of the fourth row.
// @field m44 fourth element of the fourth row.
export type M44
	// row 1
	float m11
	float m12
	float m13
	float m14
	// row 2
	float m21
	float m22
	float m23
	float m24
	// row 3
	float m31
	float m32
	float m33
	float m34
	// row 4
	float m41
	float m42
	float m43
	float m44

//#endregion



