toxi::geom::Triangle3D toxi::geom::Triangle3D::createEquilateralFrom( Vec3D & a, Vec3D & b ) { Vec3D c = a.interpolateTo( b, 0.5 ); Vec3D dir = b.sub( a ); Vec3D n = a.cross( dir.normalize( ) ); c.addSelf( n.normalizeTo( dir.magnitude() * toxi::math::MathUtils::SQRT3 / 2 ) ); return Triangle3D( a, b, c ); }
// Returns the angle between two Vecs double angle_between(Vec3D<Type> v){ return(atan(dot_product(v)/(magnitude() * v.magnitude()))); }
// Return the magnitude of a Vec with a direction // perpendicular to the plane containing this and v double cross_product(Vec3D<Type> v){ return (magnitude()*v.magnitude()*sin(angle_between(v))); }