// Example of using the vector library #include #include #include "vec3.h" int main() { Vec3 v0,v1,v2; cout << "enter three vectors"; cin >> v0; cin >> v1; cin >> v2; cout << "Area of the parallelogram spanned by the first two vectors is: " << cross(v0,v1).length() << endl; cerr << "Volume of the parallelogram spanned by the vectors is: " << fabs(dot(cross(v0,v1),v2)) << endl; cerr << "Vectors along the edges of the triangle (v0,v1,v2): " << "[" << v1-v0 << "] [" << v2-v1 << "] [" << v0-v2 << endl; cerr << "Normal to the plane of the triangle, unnormalized: [" << cross(v1-v0, v2-v0) << "]" << " normalized: [" << cross(v1-v0, v2-v0).dir() << "]" << endl; cerr << "Distance from v0 to the line connecting v1,v2 is:" << ( v1-v0 - ( dot(v1-v0,v2-v1)/(v2-v1).dot() )*(v2-v1) ).length() << endl; return 0; }