/* * MathPlanner 3.2 - Mathematical design tool. * Copyright(C) 2003 Jarmo Nikkanen * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation. * * You should have received a copy of the GNU General Public License with this program. * */ // VECTOR MATH #include "MathHeaders.h" mpl_vector mpl_cross(mpl_vector a,mpl_vector b) { mpl_vector v; v.i=a.j*b.k-a.k*b.j; v.j=a.i*b.k-a.k*b.i; v.k=a.i*b.j-a.j*b.i; return(v); } mpl_vector mpl_neg(mpl_vector a) { mpl_vector v; v.i=-a.i; v.j=-a.j; v.k=-a.k; return(v); } mpl_real mpl_length(mpl_vector a) { return(sqrt(a.i*a.i+a.j*a.j+a.k*a.k)); } mpl_vector mpl_unit_vector(mpl_vector a) { mpl_vector v; mpl_real l=mpl_length(a); if (l>0) { v.i=a.i/l; v.j=a.j/l; v.k=a.k/l; } else v.i=v.j=v.k=0; return(v); }