12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #include <cmath>
- #include "math/Vector.h"
- template<>
- Vector<3>& Vector<3>::set(float x, float y, float z) {
- values[0] = x;
- values[1] = y;
- values[2] = z;
- return *this;
- }
- template<>
- Vector<3>::Vector(float x, float y, float z) {
- set(x, y, z);
- }
- template<>
- Vector<2>& Vector<2>::set(float x, float y) {
- values[0] = x;
- values[1] = y;
- return *this;
- }
- template<>
- Vector<2>::Vector(float x, float y) {
- set(x, y);
- }
- template<>
- Vector<3>& Vector<3>::setAngles(float lengthAngle, float widthAngle) {
- lengthAngle *= (M_PI / 180.0f);
- widthAngle *= (M_PI / 180.0f);
- float sinWidth;
- float cosWidth;
- sincosf(widthAngle, &sinWidth, &cosWidth);
- float sinLength;
- float cosLength;
- sincosf(lengthAngle, &sinLength, &cosLength);
- return set(cosWidth * cosLength, sinWidth, -sinLength * cosWidth);
- }
- template<>
- Vector<3> Vector<3>::cross(const Vector<3>& other) const {
- return Vector<3>(
- values[1] * other.values[2] - values[2] * other.values[1],
- values[2] * other.values[0] - values[0] * other.values[2],
- values[0] * other.values[1] - values[1] * other.values[0]);
- }
|