/******************************************************************** * Description: * Author: George-Catalin Serbanut * * Copyright (c) 2005 George-Catalin Serbanut All rights reserved. * ********************************************************************/ /* * 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; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include "include/math.hh" #include "include/point.hh" #include "include/angles.hh" using namespace std; int Math::precision=12; Math::Math() { } Math::~Math() { } double Math::Abs(double d) { double ld = d; if(d<0.0) ld = (-1.0)*d; return ld; } double Math::Sign(double d) { double ld = 1.0; if(d<0.0) ld = -1.0; return ld; } float Math::Sign(float f) { float lf = 1.0; if(f<0.0) lf = -1.0; return lf; } int Math::Sign(int i) { int li = 1; if(i<0) li = -1; return li; } double Math::Precision(double d, int i) { double ld = d; long int lid; for(int e=0; e(ld); ld = (1.0)*static_cast(lid); for(int e=0; e Math::get_coplanarity(vector P, vector line) { PointD lp, lpc; vector lvp; int prec = Math::precision; int vas; double chi_p, psi_p, omega_p; //perp double chi_l, psi_l, omega_l; //(C1,C2) vector matrix; PointD column, column_free; double det, deti[3]; if(P.size()>=3) { if(line.size()==2) { if(!Math::coplanarity_check(P)) { vas = Math::vangles.size(); chi_p = 0.0; psi_p = 0.0; omega_p = 0.0; for(int i=0; i(vas); psi_p /= static_cast(vas); omega_p /= static_cast(vas); if(!Math::vangles.empty()) Math::vangles.clear(); Math::vangles = compute_angles(line); chi_l = vangles[0].chi; psi_l = vangles[0].psi; omega_l = vangles[0].omega; cout< P) { bool coplanarity = true; double perp_x, perp_y, perp_z, x[3], y[3], z[3], chi, psi, omega; bool chi_b, psi_b, omega_b; int prec = Math::precision; PointD perp; vector vperp; if(!Math::vangles.empty()) Math::vangles.clear(); if(P.size()>=3) { for(int cont1=0; cont11){ chi_b = false; psi_b = false; omega_b = false; for(int cont1=0; cont1 Math::compute_angles(vector P) { vector vangs; Angles angs; double perp_x, perp_y, perp_z, x[3], y[3], z[3]; if(P.size()<1) { cout<<"Warning: No point to define the angles!"< Math::add_elements(vector vangs1, vector vangs2) { vector lvangs; for(int i=0; i Matrix) { double det = 0.0; double a[3][3]; cout<<"Determinant section:"< Math::operator= (vector angs) { return angs; } PointD Math::operator= (PointD pd) { return pd; } vector Math::operator= (vector vpd) { return vpd; } */