Vector.cpp 779 B

1234567891011121314151617181920212223242526
  1. #include <cmath>
  2. #include "math/Vector.h"
  3. template<>
  4. Vector<3>& Vector<3>::setAngles(float lengthAngle, float widthAngle) {
  5. lengthAngle *= (M_PI / 180.0f);
  6. widthAngle *= (M_PI / 180.0f);
  7. float sinWidth;
  8. float cosWidth;
  9. sincosf(widthAngle, &sinWidth, &cosWidth);
  10. float sinLength;
  11. float cosLength;
  12. sincosf(lengthAngle, &sinLength, &cosLength);
  13. return *this = Vector<3>(cosWidth * cosLength, sinWidth, -sinLength * cosWidth);
  14. }
  15. template<>
  16. Vector<3> Vector<3>::cross(const Vector<3>& other) const {
  17. return Vector<3>(values[1] * other.values[2] - values[2] * other.values[1],
  18. values[2] * other.values[0] - values[0] * other.values[2],
  19. values[0] * other.values[1] - values[1] * other.values[0]);
  20. }