convert transform to affine matrix
This commit is contained in:
parent
cd17583f63
commit
e2a9084df1
@ -20,6 +20,7 @@
|
|||||||
#define B3_TRANSFORM_H
|
#define B3_TRANSFORM_H
|
||||||
|
|
||||||
#include <bounce/common/math/mat33.h>
|
#include <bounce/common/math/mat33.h>
|
||||||
|
#include <bounce/common/math/mat44.h>
|
||||||
#include <bounce/common/math/quat.h>
|
#include <bounce/common/math/quat.h>
|
||||||
|
|
||||||
// A transform represents a rigid frame.
|
// A transform represents a rigid frame.
|
||||||
@ -59,6 +60,16 @@ struct b3Transform
|
|||||||
// Identity transformation
|
// Identity transformation
|
||||||
extern const b3Transform b3Transform_identity;
|
extern const b3Transform b3Transform_identity;
|
||||||
|
|
||||||
|
// Convert a transform to a 4-by-4 transformation matrix.
|
||||||
|
inline b3Mat44 b3TransformMat44(const b3Transform& T)
|
||||||
|
{
|
||||||
|
return b3Mat44(
|
||||||
|
b3Vec4(T.rotation.x.x, T.rotation.x.y, T.rotation.x.z, 0.0f),
|
||||||
|
b3Vec4(T.rotation.y.x, T.rotation.y.y, T.rotation.y.z, 0.0f),
|
||||||
|
b3Vec4(T.rotation.z.x, T.rotation.z.y, T.rotation.z.z, 0.0f),
|
||||||
|
b3Vec4(T.position.x, T.position.y, T.position.z, 1.0f));
|
||||||
|
}
|
||||||
|
|
||||||
// Multiply a transform times a vector.
|
// Multiply a transform times a vector.
|
||||||
inline b3Vec3 b3Mul(const b3Transform& T, const b3Vec3& v)
|
inline b3Vec3 b3Mul(const b3Transform& T, const b3Vec3& v)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user