X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;ds=sidebyside;f=include%2Fla.h;h=0ef6ee8210432e27fd937acc843e620ac555fcde;hb=4b7b856e70fe8047f985e2598020032d0d87a672;hp=e0fe84df6131bac770293103b7c93ddbae117f38;hpb=1c78f8bbdfe52be741185762123fba2c169d738a;p=meshio%2Fmeshio.git diff --git a/include/la.h b/include/la.h index e0fe84d..0ef6ee8 100644 --- a/include/la.h +++ b/include/la.h @@ -21,11 +21,13 @@ struct Vector2 : x(_x), y(_y) {} }; +#ifndef SWIG inline std::ostream &operator<<(std::ostream &os, const Vector2 &rhs) { return os << '[' << rhs.x << ',' << rhs.y << ']'; } +#endif struct Vector3 @@ -45,12 +47,24 @@ struct Vector3 { return x==rhs.x && y==rhs.y && z==rhs.z; } + + Vector3 operator+(const Vector3 &rhs) + { + return Vector3(x+rhs.x, y+rhs.y, z+rhs.z); + } + + Vector3 operator-(const Vector3 &rhs) + { + return Vector3(x-rhs.x, y-rhs.y, z-rhs.z); + } }; +#ifndef SWIG inline std::ostream &operator<<(std::ostream &os, const Vector3 &rhs) { return os << '[' << rhs.x << ',' << rhs.y << ',' << rhs.z << ']'; } +#endif struct Vector4 @@ -67,11 +81,13 @@ struct Vector4 : x(_x), y(_y), z(_z), w(_w) {} }; +#ifndef SWIG inline std::ostream &operator<<(std::ostream &os, const Vector4 &rhs) { return os << '[' << rhs.x << ',' << rhs.y << ',' << rhs.z << ',' << rhs.w << ']'; } +#endif struct Quaternion @@ -87,12 +103,19 @@ struct Quaternion Quaternion(float _x, float _y, float _z, float _w) : x(_x), y(_y), z(_z), w(_w) {} + + float dot(const Quaternion &rhs) + { + return x*rhs.x + y*rhs.y + z*rhs.z + w*rhs.w; + } }; +#ifndef SWIG inline std::ostream &operator<<(std::ostream &os, const Quaternion &rhs) { return os << '[' << rhs.x << ',' << rhs.y << ',' << rhs.z << ',' << rhs.w << ']'; } +#endif }