-
Notifications
You must be signed in to change notification settings - Fork 31
PyGLM Types
PyGLM brings a couple of types with it.
These types represent either vectors, matrices or quaternions.
-
A vector usually is an array of 1 to 4 numbers that serve as positions or directions in a
1 to 4 dimensional coordinate system (respectively).
They support a lot of operations necessary in linear algebra.
Vector types are expressed as glm.vecN (N being the length).
For example a 2D vector would be expressed asglm.vec2. -
A matrix is a 2 dimensional array of numbers ranging from 2x2 (4 numbers) to 4x4 (16 numbers).
They aid in a lot of complex vector manipulations.
Matrix types are expressed as glm.matNxM (N being the columns and M being the rows).
So a 4x4 matrix would beglm.mat4x4, orglm.mat4for short (because N and M are equal).
Note: Yes, columns and rows are not in the natural order - this is a flaw of glm. -
A quaternion is an array of 4 numbers that can be used for complex vector manipulations.
They are made up of a scalar part(w)and a vector part(x, y, z)and are sometimes displayed as
(w + x*i + y*j + z*k), wherei,jandkare imaginary numbers.
Quaternion types are simply expressed asglm.quat.
All of these types use 32-bit floating point numbers to store their values.
PyGLM does however provide other data types.
For all of the aforementioned:
| Data type | Description | Prefix |
|---|---|---|
| double | 64-bit floating point number |
d or f64
|
| float | 32-bit floating point number |
f or f32 or none |
Additionally for matrices and vectors:
| Data type | Description | Prefix |
|---|---|---|
| int | 32-bit signed integer |
i or i32
|
| uint | 32-bit unsigned integer |
u or u32
|
And additionally for vectors:
| Data type | Description | Prefix |
|---|---|---|
| int64 | 64-bit signed integer | i64 |
| int16 | 16-bit signed integer | i16 |
| int8 | 8-bit signed integer | i8 |
| uint64 | 64-bit unsigned integer | u64 |
| uint16 | 16-bit unsigned integer | u16 |
| uint8 | 8-bit unsigned integer | u8 |
| bool | boolean values | b |
If for example you want to use a 2D int64 vector, the type you want to use would be glm.i64vec2.