本文整理汇总了C++中vec3::Cross方法的典型用法代码示例。如果您正苦于以下问题:C++ vec3::Cross方法的具体用法?C++ vec3::Cross怎么用?C++ vec3::Cross使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec3
的用法示例。
在下文中一共展示了vec3::Cross方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Rotation
const Quaternion Quaternion::Rotation(const vec3& unitVec0, const vec3& unitVec1)
{
float cosHalfAngleX2, recipCosHalfAngleX2;
cosHalfAngleX2 = sqrt((2.0f * (1.0f + unitVec0.Dot(unitVec1))));
recipCosHalfAngleX2 = (1.0f / cosHalfAngleX2);
return Quaternion((unitVec0.Cross(unitVec1) * recipCosHalfAngleX2), (cosHalfAngleX2 * 0.5f));
}
示例2: set
void Camera::set(const vec3& eyepos, const vec3& look, const vec3& up)
{
eye = eyepos;
n = eyepos - look;
v = up.Cross(n);
u = n.Cross(v);
mRadius = n.Length(); // cache this distance
u.Normalize();
v.Normalize();
n.Normalize();
}
示例3: set
void ACamera::set(const vec3& eyepos, const vec3& look, const vec3& up)
{
mEye = eyepos;
mN = eyepos - look;
mV = up.Cross(mN);
mU = mN.Cross(mV);
mRadius = mN.Length(); // cache this distance
mU.Normalize();
mV.Normalize();
mN.Normalize();
}
示例4: CreateFromVectors
static CQuaternion CreateFromVectors(vec3 v0, vec3 v1) {
CQuaternion q;
if (v0 == -v1) {//Create from Axis Angle
//int a = 1;
}
vec3 c = v0.Cross(v1);
float d = v0.Dot(v1);
float s = (float) sqrt((1+d)*2);
q.x = c.x /s;
q.y = c.y/s;
q.z = c.z/s;
q.w = s / 2.0f;
return q;
}
示例5: FreeCamera
const mat4 FreeCamera(vec3 eye, vec3 dir, vec3 up)
{
// Builds a look-at style view matrix.
// This is essentially the same matrix used by gluLookAt().
vec3 target = eye + dir;
vec3 zAxis = eye - target;
zAxis.Normalize();
vec3 xAxis = up.Cross(zAxis);
xAxis.Normalize();
vec3 yAxis = zAxis.Cross(xAxis);
yAxis.Normalize();
mat4 res;
float* m = &res[0];
m[0*4 + 0] = xAxis[0];
m[1*4 + 0] = xAxis[1];
m[2*4 + 0] = xAxis[2];
m[3*4 + 0] = -xAxis.Dot(eye);
m[0*4 + 1] = yAxis[0];
m[1*4 + 1] = yAxis[1];
m[2*4 + 1] = yAxis[2];
m[3*4 + 1] = -yAxis.Dot(eye);
m[0*4 + 2] = zAxis[0];
m[1*4 + 2] = zAxis[1];
m[2*4 + 2] = zAxis[2];
m[3*4 + 2] = -zAxis.Dot(eye);
m[0*4 + 3] = 0.0f;
m[1*4 + 3] = 0.0f;
m[2*4 + 3] = 0.0f;
m[3*4 + 3] = 1.0f;
return res;
}
示例6:
void RigidBody3::ApplyForceAtBodyPoint(const vec3& force, const vec3& point)
{
// forces += force;
torques += force.Cross( modelMatrix.RotateFromLocalToGlobal(point) );
}