Vector.cpp 761 B

12345678910111213141516171819202122
  1. #include "math/Vector.h"
  2. template<>
  3. Vector3& Vector3::setAngles(float lengthAngle, float widthAngle) {
  4. float sWidth = 0.0f;
  5. float cWidth = 0.0f;
  6. sincosf(widthAngle * (static_cast<float>(M_PI) / 180.0f), &sWidth, &cWidth);
  7. float sLength = 0.0f;
  8. float cLength = 0.0f;
  9. sincosf(lengthAngle * (static_cast<float>(M_PI) / 180.0f), &sLength,
  10. &cLength);
  11. return *this = Vector3(cWidth * cLength, sWidth, -sLength * cWidth);
  12. }
  13. template<>
  14. Vector3 Vector3::cross(const Vector3& other) const {
  15. return Vector3(values[1] * other.values[2] - values[2] * other.values[1],
  16. values[2] * other.values[0] - values[0] * other.values[2],
  17. values[0] * other.values[1] - values[1] * other.values[0]);
  18. }