0

I'm looking for what exactly is a Vector3 (or any Vector for that matter) and also what a Quaternion is in code?
What are the variables types? Should you have multiple classes for each type?

Thanks!

3
Contributors
2
Replies
16
Views
1 Year
Discussion Span
Last Post by ddanbe
0

I'm looking for what exactly is a Vector3 (or any Vector for that matter) and also what a Quaternion is in code? What are the variables types? Should you have multiple classes for each type?

Depends on the language you're using, and even then, there are multiple ways to represent vectors and quaternions.

Vectors in R3 can be simple structures with x, y, and z members, or you can use an array-like member to hold those values instead. You'll need arrays (or equivalent) to represent generic vectors in Rn though. If you're going to be working with matrices, you might also consider using a 1xn or nx1 matrix for your vectors.

The actual member type will be something "close enough" to a real number. For practical purposes, this is usually a single- or double-precision floating point value, unless you're doing something special, which is an entirely different conversation.

Then there are vector operations--some are only defined for vectors of certain sizes, and others, while they can be written generically for any size vector, have alternate implementations that are smaller and/or faster for certain sizes. Depending on your language, you may be able to take advantage of inheritance and/or templates to avoid writing duplicate code.

The quaternions (denoted H) are equivalent to vectors in R4, just with special operations.

Edited by gusano79

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.