Show
Ignore:
Timestamp:
03/21/12 18:36:20 (2 years ago)
Author:
robert
Message:

Ran script to remove trailing spaces and tabs

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osg/Quat.cpp

    r11472 r13041  
    1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield  
     1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 
    22 * 
    3  * This library is open source and may be redistributed and/or modified under   
    4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or  
     3 * This library is open source and may be redistributed and/or modified under 
     4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
    55 * (at your option) any later version.  The full license is in LICENSE file 
    66 * included with this distribution, and on the openscenegraph.org website. 
    7  *  
     7 * 
    88 * This library is distributed in the hope that it will be useful, 
    99 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
     10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1111 * OpenSceneGraph Public License for more details. 
    1212*/ 
     
    8282 
    8383 
    84 void Quat::makeRotate ( value_type angle1, const Vec3f& axis1,  
     84void Quat::makeRotate ( value_type angle1, const Vec3f& axis1, 
    8585                        value_type angle2, const Vec3f& axis2, 
    8686                        value_type angle3, const Vec3f& axis3) 
     
    8989               angle2,Vec3d(axis2), 
    9090               angle3,Vec3d(axis3)); 
    91 }                         
    92  
    93 void Quat::makeRotate ( value_type angle1, const Vec3d& axis1,  
     91} 
     92 
     93void Quat::makeRotate ( value_type angle1, const Vec3d& axis1, 
    9494                        value_type angle2, const Vec3d& axis2, 
    9595                        value_type angle3, const Vec3d& axis3) 
     
    100100 
    101101    *this = q1*q2*q3; 
    102 }                         
     102} 
    103103 
    104104 
     
    110110/** Make a rotation Quat which will rotate vec1 to vec2 
    111111 
    112 This routine uses only fast geometric transforms, without costly acos/sin computations.  
     112This routine uses only fast geometric transforms, without costly acos/sin computations. 
    113113It's exact, fast, and with less degenerate cases than the acos/sin method. 
    114114 
    115 For an explanation of the math used, you may see for example:  
     115For an explanation of the math used, you may see for example: 
    116116http://logiciels.cnes.fr/MARMOTTES/marmottes-mathematique.pdf 
    117117 
    118 @note This is the rotation with shortest angle, which is the one equivalent to the  
    119 acos/sin transform method. Other rotations exists, for example to additionally keep  
     118@note This is the rotation with shortest angle, which is the one equivalent to the 
     119acos/sin transform method. Other rotations exists, for example to additionally keep 
    120120a local horizontal attitude. 
    121121 
     
    125125{ 
    126126 
    127     // This routine takes any vector as argument but normalized  
     127    // This routine takes any vector as argument but normalized 
    128128    // vectors are necessary, if only for computing the dot product. 
    129129    // Too bad the API is that generic, it leads to performance loss. 
     
    134134    Vec3d sourceVector = from; 
    135135    Vec3d targetVector = to; 
    136      
     136 
    137137    value_type fromLen2 = from.length2(); 
    138138    value_type fromLen; 
     
    142142        sourceVector /= fromLen; 
    143143    } else fromLen = 1.0; 
    144      
     144 
    145145    value_type toLen2 = to.length2(); 
    146146    // normalize only when necessary, epsilon test 
     
    150150        if ((toLen2 > fromLen2-1e-7) && (toLen2 < fromLen2+1e-7)) { 
    151151            toLen = fromLen; 
    152         }  
     152        } 
    153153        else toLen = sqrt(toLen2); 
    154154        targetVector /= toLen; 
    155155    } 
    156156 
    157      
     157 
    158158    // Now let's get into the real stuff 
    159159    // Use "dot product plus one" as test as it can be re-used later on 
    160160    double dotProdPlus1 = 1.0 + sourceVector * targetVector; 
    161      
     161 
    162162    // Check for degenerate case of full u-turn. Use epsilon for detection 
    163163    if (dotProdPlus1 < 1e-7) { 
    164      
     164 
    165165        // Get an orthogonal vector of the given vector 
    166166        // in a plane with maximum vector coordinates. 
     
    169169        if (fabs(sourceVector.x()) < 0.6) { 
    170170            const double norm = sqrt(1.0 - sourceVector.x() * sourceVector.x()); 
    171             _v[0] = 0.0;  
     171            _v[0] = 0.0; 
    172172            _v[1] = sourceVector.z() / norm; 
    173173            _v[2] = -sourceVector.y() / norm; 
     
    187187        } 
    188188    } 
    189      
     189 
    190190    else { 
    191191        // Find the shortest angle quaternion that transforms normalized vectors 
     
    212212    value_type length1  = from.length(); 
    213213    value_type length2  = to.length(); 
    214      
     214 
    215215    // dot product vec1*vec2 
    216216    value_type cosangle = from*to/(length1*length2); 
     
    219219    { 
    220220        OSG_INFO<<"*** Quat::makeRotate(from,to) with near co-linear vectors, epsilon= "<<fabs(cosangle-1)<<std::endl; 
    221      
     221 
    222222        // cosangle is close to 1, so the vectors are close to being coincident 
    223223        // Need to generate an angle of zero with any vector we like 
     
    236236        else if (fabs(from.y())<fabs(from.z())) tmp.set(0.0,1.0,0.0); 
    237237        else tmp.set(0.0,0.0,1.0); 
    238          
     238 
    239239        Vec3d fromd(from.x(),from.y(),from.z()); 
    240          
     240 
    241241        // find orthogonal axis. 
    242242        Vec3d axis(fromd^tmp); 
    243243        axis.normalize(); 
    244          
     244 
    245245        _v[0] = axis[0]; // sin of half angle of PI is 1.0. 
    246246        _v[1] = axis[1]; // sin of half angle of PI is 1.0. 
     
    310310    const double epsilon = 0.00001; 
    311311    double omega, cosomega, sinomega, scale_from, scale_to ; 
    312      
     312 
    313313    osg::Quat quatTo(to); 
    314314    // this is a dot product 
    315      
     315 
    316316    cosomega = from.asVec4() * to.asVec4(); 
    317      
     317 
    318318    if ( cosomega <0.0 ) 
    319     {  
    320         cosomega = -cosomega;  
     319    { 
     320        cosomega = -cosomega; 
    321321        quatTo = -to; 
    322322    } 
     
    342342 
    343343    *this = (from*scale_from) + (quatTo*scale_to); 
    344      
     344 
    345345    // so that we get a Vec4 
    346346} 
     
    358358    osg::Quat q; 
    359359    q.makeRotate(heading,pitch,roll); 
    360      
     360 
    361361    osg::Matrix q_m; 
    362362    q.get(q_m); 
    363      
     363 
    364364    osg::Vec3 xAxis(1,0,0); 
    365365    osg::Vec3 yAxis(0,1,0); 
    366366    osg::Vec3 zAxis(0,0,1); 
    367      
     367 
    368368    cout << "heading = "<<heading<<"  pitch = "<<pitch<<"  roll = "<<roll<<endl; 
    369369 
     
    372372    cout <<"yAxis*q_m = "<<yAxis*q_m << endl; 
    373373    cout <<"zAxis*q_m = "<<zAxis*q_m << endl; 
    374      
     374 
    375375    osg::Matrix r_m = osg::Matrix::rotate(roll,0.0,1.0,0.0)* 
    376376                      osg::Matrix::rotate(pitch,1.0,0.0,0.0)* 
    377377                      osg::Matrix::rotate(-heading,0.0,0.0,1.0); 
    378                        
     378 
    379379    cout << "r_m = "<<r_m; 
    380380    cout <<"xAxis*r_m = "<<xAxis*r_m << endl; 
    381381    cout <<"yAxis*r_m = "<<yAxis*r_m << endl; 
    382382    cout <<"zAxis*r_m = "<<zAxis*r_m << endl; 
    383      
     383 
    384384    cout << endl<<"*****************************************" << endl<< endl; 
    385      
     385 
    386386} 
    387387