如何从方向创建旋转矩阵(单位矢量)
我的矩阵是3x3,专栏和右手
我知道'column1'是正确的,'column2'是向上的,'column3'是向前的
但我不能这样做.
//3x3, Right Hand
struct Mat3x3
{
Vec3 column1;
Vec3 column2;
Vec3 column3;
void makeRotationDir(const Vec3& direction)
{
//:((
}
}
Run Code Online (Sandbox Code Playgroud) 告诉我哪一个更快:sub或者mul?
我的目标平台是X86; FPU和SSE.
例:
'LerpColorSolution1'使用乘法.
'LerpColorSolution2'使用减法.
哪个更快?
void LerpColorSolution1(const float* a, const float* b, float alpha, float* out)
{
out[0] = a[0] + (b[0] - a[0]) * alpha;
out[1] = a[1] + (b[1] - a[1]) * alpha;
out[2] = a[2] + (b[2] - a[2]) * alpha;
out[3] = a[3] + (b[3] - a[3]) * alpha;
}
void LerpColorSolution2(const float* a, const float* b, float alpha, float* out)
{
float f = 1.0f - alpha;
out[0] = …Run Code Online (Sandbox Code Playgroud)