Exemplo n.º 1
0
double Vector3d::distance( Vector3d a, Vector3d b, Vector3d c ) {
    // calculate 2 displacement vectors in plane
    b.subtract( a );
    c.subtract( a );
    // calculate normal vector
    Vector3d n = b.crossProduct( c );
    Vector3d p = *this;
    p.subtract( a );
    return n.dotProduct( p ) / n.absoluteValue();
}
Exemplo n.º 2
0
double Vector3d::distance( Vector3d v ) {
    // calculate displacement vector
    v.subtract( *this );
    // return absolute value of displacement vector
    return v.absoluteValue();
}