public idVec3 ToAngularVelocity() { idVec3 vec = new idVec3(); vec.x = x; vec.y = y; vec.z = z; vec.Normalize(); return(vec * idMath.ACos(w)); }
public idRotation ToRotation() { if (pitch == 0.0f) { if (yaw == 0.0f) { return(new idRotation(idvec3.origin, new idVec3(-1.0f, 0.0f, 0.0f), roll)); } if (roll == 0.0f) { return(new idRotation(idVec3.origin, new idVec3(0.0f, 0.0f, -1.0f), yaw)); } } else if (yaw == 0.0f && roll == 0.0f) { return(new idRotation(idVec3.origin, new idVec3(0.0f, -1.0f, 0.0f), pitch)); } float sx, cx, sy, cy, sz, cz; idMath.SinCos(DEG2RAD(yaw) * 0.5f, out sz, out cz); idMath.SinCos(DEG2RAD(pitch) * 0.5f, out sy, out cy); idMath.SinCos(DEG2RAD(roll) * 0.5f, out sx, out cx); float sxcy = sx * cy; float cxcy = cx * cy; float sxsy = sx * sy; float cxsy = cx * sy; // idVec3 vec = new idVec3(); vec.x = cxsy * sz - sxcy * cz; vec.y = -cxsy * cz - sxcy * sz; vec.z = sxsy * cz - cxcy * sz; float w = cxcy * cz + sxsy * sz; float angle = idMath.ACos(w); if (angle == 0.0f) { vec.Set(0.0f, 0.0f, 1.0f); } else { //vec *= (1.0f / sin( angle )); vec.Normalize(); vec.FixDegenerateNormal(); angle *= 2.0f * idMath.M_RAD2DEG; } return(new idRotation(idVec3.origin, vec, angle)); }
public static bool ProjectAlongPlane(idVec3 t, idVec3 normal, float epsilon, float overBounce) { idVec3 cross = t.Cross(normal).Cross(t); // normalize so a fixed epsilon can be used cross.Normalize(); float len = normal * cross; if (idMath.Fabs(len) < epsilon) { return(false); } cross.opMul(overBounce * (normal * t) / len); t.opSub(cross); return(true); }
public idRotation ToRotation() { idVec3 vec = new idVec3(); vec.x = x; vec.y = y; vec.z = z; float angle = idMath.ACos(w); if (angle == 0.0f) { vec.Set(0.0f, 0.0f, 1.0f); } else { //vec *= (1.0f / sin( angle )); vec.Normalize(); vec.FixDegenerateNormal(); angle *= 2.0f * idMath.M_RAD2DEG; } return(new idRotation(idVec3.origin, vec, angle)); }
public idVec3 ToAngularVelocity() { idVec3 vec = new idVec3(); vec.x = x; vec.y = y; vec.z = z; vec.Normalize(); return vec * idMath.ACos(w); }
public idRotation ToRotation() { idVec3 vec = new idVec3(); vec.x = x; vec.y = y; vec.z = z; float angle = idMath.ACos(w); if (angle == 0.0f) { vec.Set(0.0f, 0.0f, 1.0f); } else { //vec *= (1.0f / sin( angle )); vec.Normalize(); vec.FixDegenerateNormal(); angle *= 2.0f * idMath.M_RAD2DEG; } return new idRotation(idVec3.origin, vec, angle); }
public idRotation ToRotation() { if (pitch == 0.0f) { if (yaw == 0.0f) return new idRotation(idvec3.origin, new idVec3(-1.0f, 0.0f, 0.0f), roll); if (roll == 0.0f) return new idRotation(idVec3.origin, new idVec3(0.0f, 0.0f, -1.0f), yaw); } else if (yaw == 0.0f && roll == 0.0f) return new idRotation(idVec3.origin, new idVec3(0.0f, -1.0f, 0.0f), pitch); float sx, cx, sy, cy, sz, cz; idMath.SinCos(DEG2RAD(yaw) * 0.5f, out sz, out cz); idMath.SinCos(DEG2RAD(pitch) * 0.5f, out sy, out cy); idMath.SinCos(DEG2RAD(roll) * 0.5f, out sx, out cx); float sxcy = sx * cy; float cxcy = cx * cy; float sxsy = sx * sy; float cxsy = cx * sy; // idVec3 vec = new idVec3(); vec.x = cxsy * sz - sxcy * cz; vec.y = -cxsy * cz - sxcy * sz; vec.z = sxsy * cz - cxcy * sz; float w = cxcy * cz + sxsy * sz; float angle = idMath.ACos(w); if (angle == 0.0f) vec.Set(0.0f, 0.0f, 1.0f); else { //vec *= (1.0f / sin( angle )); vec.Normalize(); vec.FixDegenerateNormal(); angle *= 2.0f * idMath.M_RAD2DEG; } return new idRotation(idVec3.origin, vec, angle); }