void Vec3F::rotate(float p_angle, const Vec3F& p_axis) {
    const float sinHalfAngle = sinf((float)RADIAN(p_angle / 2));
    const float cosHalfAngle = cosf((float)RADIAN(p_angle / 2));

    const float rX = p_axis.x * sinHalfAngle;
    const float rY = p_axis.y * sinHalfAngle;
    const float rZ = p_axis.z * sinHalfAngle;
    const float rW = cosHalfAngle;

    Quaternion rotationQ(rX, rY, rZ, rW);
    Quaternion conjugateQ = rotationQ.conjugate();
    Quaternion w = rotationQ * (*this) * conjugateQ;

    x = w.x;
    y = w.y;
    z = w.z;
}
Esempio n. 2
0
void Vector3f::Rotate(float angle, const Vector3f& axis)
{
	const float sinHalfAngle = sin(ToRadian(angle / 2));
	const float cosHalfAngle = cos(ToRadian(angle / 2));

	const float Rx = axis.x * sinHalfAngle;
	const float Ry = axis.y * sinHalfAngle;
	const float Rz = axis.z * sinHalfAngle;
	const float Rw = cosHalfAngle;

	Quaternion rotationQ(Rx, Ry, Rz, Rw);
	Quaternion conjugateQ = rotationQ.Conjugate();
	Quaternion W = rotationQ * (*this) * conjugateQ;

	x = W.x;
	y = W.y;
	z = W.z;
}
Esempio n. 3
0
Vector3 Vector3::rotate(float angle,const Vector3& axis) const{
	const float sinHalfAngle = sinf(ToRadian(angle/2));
	const float cosHalfAngle = cosf(ToRadian(angle/2));

	const float Rx = axis.x * sinHalfAngle;
	const float Ry = axis.y * sinHalfAngle;
	const float Rz = axis.z * sinHalfAngle;
	const float Rw = cosHalfAngle;

	Quaternion rotationQ(Rx,Ry,Rz,Rw);

	Quaternion conjugateQ = rotationQ.conjugate();
	Quaternion w = rotationQ *(*this) * conjugateQ;

	Vector3 ret(w.x,w.y,w.z);

	return ret;
}
Esempio n. 4
0
void Vector3f::rotate(float angle, const Vector3f axis)
{
    const float sinHalfAngle = sinf(toRadian(angle / 2));
    const float cosHalfAngle = cosf(toRadian(angle / 2));

    const float rx = axis.x() * sinHalfAngle;
    const float ry = axis.y() * sinHalfAngle;
    const float rz = axis.z() * sinHalfAngle;
    const float rw = cosHalfAngle;

    Quaternion rotationQ(rx, ry, rz, rw);

    Quaternion conjugateQ = rotationQ.conjugate();

    Quaternion w = rotationQ * (*this) * conjugateQ;

    m_[0] = w.x();
    m_[1] = w.y();
    m_[2] = w.z();
}