public static Vector3d operator *(float N,Vector3d vct2) { Vector3d vct = new Vector3d(0,0,0); vct.m_x = N*vct2.get_x(); vct.m_y = N*vct2.get_y(); vct.m_z = N*vct2.get_z(); return vct; }
public static Vector3d operator +(Vector3d vct1, Vector3d vct2) { Vector3d vct = new Vector3d(0,0,0); vct.m_x = vct1.get_x() + vct2.get_x(); vct.m_y = vct1.get_y() + vct2.get_y(); vct.m_z = vct1.get_z() + vct2.get_z(); return vct; }
public float dot_product(Vector3d vct2) { // v1->.v2-> = x1*x2 + y1*y2 + z1*z2 // How to call : // Vector3d v1 = new Vector3d(1,0,0); // Vector3d v2 = new Vector3d(0,1,0); // v1.dot_product(v2) return float 0 return this.get_x()*vct2.get_x() + this.get_y()*vct2.get_y() + this.get_z()*vct2.get_z(); }
public float distance(float x, float y) { float d=0; Vector3d vct = new Vector3d(0,0,0); Vector3d vct2 = new Vector3d(x,y,0); vct = vct2 - this; d = vct.norm; // norm is a property return d; }
public Vector3d cross_product(Vector3d vct2) { // How to call : // Vector3d v1 = new Vector3d(1,0,0); // Vector3d v2 = new Vector3d(0,1,0); // v1.cross_product(v2) return Vector3d (0 0 1) Vector3d vct = new Vector3d(0,0,0); // v1->^v2-> = v-> // vx = y1 z2 - y2 z1 vct.set_x( this.get_y() * vct2.get_z() - vct2.get_y() * this.get_z() ); // vy = z1 x2 - x1 z2 vct.set_y( this.get_z() * vct2.get_x() - this.get_x() * vct2.get_z() ); // vz = x1 y2 - y1 x2 vct.set_z( this.get_x() * vct2.get_y() - this.get_y() * vct2.get_x() ); return vct; }
/* public static bool operator ==(Vector3d vct1, Vector3d vct2) { return (vct1 - vct2).norm==0; } public static bool operator !=(Vector3d vct1, Vector3d vct2) { return (vct1 - vct2).norm!=0; } public bool equal(Vector3d vct2) { return (this - vct2).norm==0; } */ public static Vector3d operator -(Vector3d vct1,Vector3d vct2) { Vector3d vct = new Vector3d(0,0,0); vct.m_x = vct1.m_x - vct2.m_x; vct.m_y = vct1.m_y - vct2.m_y; vct.m_z = vct1.m_z - vct2.m_z; return vct; }