public static float Angle(CM_Vector3 _v0, CM_Vector3 _v1)
    {
        float _temp = (float)(CM_Vector3.Magnitude(_v0) * CM_Vector3.Magnitude(_v1));

        _temp = (float)(Math.Acos(Dot(_v0, _v1) / _temp));

        return(RadToDeg(_temp));
    }
    public static CM_Vector3 CrossProduct(CM_Vector3 _v0, CM_Vector3 _v1)
    {
        float x = (_v0.y * _v1.z) - (_v0.z * _v1.y);
        float y = (_v0.z * _v1.x) - (_v0.x * _v1.z);
        float z = (_v0.x * _v1.y) - (_v0.y * _v1.x);

        return(new CM_Vector3(x, y, z));
    }
    public static float Dot(CM_Vector3 _v0, CM_Vector3 _v1)
    {
        float _x = _v0.x * _v1.x;
        float _y = _v0.y * _v1.y;
        float _z = _v0.z * _v1.z;

        return(_x + _y + _z);
    }
    public static double Magnitude(CM_Vector3 _v0)
    {
        float _x = _v0.x;
        float _y = _v0.y;
        float _z = _v0.z;

        return(Math.Sqrt(_x * _x + _y * _y + _z * _z));
    }
    public static CM_Vector3 Normalize(CM_Vector3 _v0)
    {
        double _magnitude = Magnitude(_v0);
        float  _x         = _v0.x / (float)_magnitude;
        float  _y         = _v0.y / (float)_magnitude;
        float  _z         = _v0.z / (float)_magnitude;

        return(new CM_Vector3(_x, _y, _z));
    }
Beispiel #6
0
 private void Start()
 {
     Debug.Log(Vector3.Angle(v0, v1));
     Debug.Log(CM_Vector3.Angle(v01, v02));
 }
 public bool Equals(CM_Vector3 other)
 {
     return(x.Equals(other.x) && y.Equals(other.y) && z.Equals(other.z));
 }