예제 #1
0
	//----------------------------------------------------------------------------------------------------
	MATRIX MatrixRotationAxis(const FLOAT3& axis, const FLOAT radians)
	{
		FLOAT3 axisN = axis.GetNormalization();

		FLOAT sinAngle = sinf(radians);
		FLOAT cosAngle = cosf(radians);
		FLOAT rmCosAngle = 1 - cosAngle;

		MATRIX result;
		result(0, 0) = (FLOAT)((axisN.x * axisN.x) * rmCosAngle + cosAngle);
		result(0, 1) = (FLOAT)((axisN.x * axisN.y) * rmCosAngle + (axisN.z * sinAngle));
		result(0, 2) = (FLOAT)((axisN.x * axisN.z) * rmCosAngle - (axisN.y * sinAngle));

		result(1, 0) = (FLOAT)((axisN.y * axisN.x) * rmCosAngle - (axisN.z * sinAngle));
		result(1, 1) = (FLOAT)((axisN.y * axisN.y) * rmCosAngle + cosAngle);
		result(1, 2) = (FLOAT)((axisN.y * axisN.z) * rmCosAngle + (axisN.x * sinAngle));

		result(2, 0) = (FLOAT)((axisN.z * axisN.x) * rmCosAngle + (axisN.y * sinAngle));
		result(2, 1) = (FLOAT)((axisN.z * axisN.y) * rmCosAngle - (axisN.x * sinAngle));
		result(2, 2) = (FLOAT)((axisN.z * axisN.z) * rmCosAngle + cosAngle);

		result(0, 3) = result(1, 3) = result(2, 3) = 0.0f;
		result(3, 0) = result(3, 1) = result(3, 2) = 0.0f;
		result(3, 3) = 1.0f;

		return result;
	}
예제 #2
0
	//----------------------------------------------------------------------------------------------------
	Quaternion QuaternionRotationAxis(const FLOAT3& _axis, const FLOAT _radians)
	{
		Quaternion result;
		FLOAT3 axis = _axis.GetNormalization();
		FLOAT ccc = cos(0.5f * _radians);
		FLOAT sss = sin(0.5f * _radians);

		result.t = ccc;
		result.x = sss * axis.x;
		result.y = sss * axis.y;
		result.z = sss * axis.z;

		return result;
	}