Vector.cpp 807 B

1234567891011121314151617181920212223242526
  1. #include <cmath>
  2. #include "math/MathConstants.h"
  3. #include "math/Vector.h"
  4. template<>
  5. Vector<3>& Vector<3>::setAngles(float lengthAngle, float widthAngle) {
  6. lengthAngle *= (M_PI / 180.0f);
  7. widthAngle *= (M_PI / 180.0f);
  8. float sinWidth = sinf(widthAngle);
  9. float cosWidth = cosf(widthAngle);
  10. float sinLength = sinf(lengthAngle);
  11. float cosLength = cosf(lengthAngle);
  12. return *this =
  13. 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. }