Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 10, 2005, 5:58:08 PM (19 years ago)
Author:
patrick
Message:

orxonox/branches/md2_loader: altered some vector functions and wiped out most of the compiler errors. still remaining one link error.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/md2_loader/src/lib/graphics/importer/abstract_model.h

    r4146 r4148  
    2525#include "base_object.h"
    2626#include <vector>
     27#include <math.h>
    2728
    2829using namespace std;
     
    111112};
    112113
     114
     115/* TESTING TESTING TESTING */
     116/* some mathematical functions that are already implemented by vector.cc class */
     117
     118// magnitude of a normal
     119#define Mag(Normal) (sqrt(Normal.x*Normal.x + Normal.y*Normal.y + Normal.z*Normal.z))
     120
     121// vector between two points
     122CVector3 VectorDiff(CVector3 vPoint1, CVector3 vPoint2)
     123{
     124        CVector3 vVector;                                                       
     125
     126        vVector.x = vPoint1.x - vPoint2.x;                     
     127        vVector.y = vPoint1.y - vPoint2.y;                     
     128        vVector.z = vPoint1.z - vPoint2.z;                     
     129
     130        return vVector;                                                         
     131}
     132
     133// adding vectors, returning result
     134CVector3 AddVector(CVector3 vVector1, CVector3 vVector2)
     135{
     136        CVector3 vResult;                                                       
     137       
     138        vResult.x = vVector2.x + vVector1.x;           
     139        vResult.y = vVector2.y + vVector1.y;           
     140        vResult.z = vVector2.z + vVector1.z;           
     141
     142        return vResult;
     143}
     144
     145// This divides a vector by a single number (scalar) and returns the result
     146CVector3 DivideVectorByScaler(CVector3 vVector1, float Scaler)
     147{
     148        CVector3 vResult;                                                       
     149       
     150        vResult.x = vVector1.x / Scaler;                       
     151        vResult.y = vVector1.y / Scaler;               
     152        vResult.z = vVector1.z / Scaler;
     153
     154        return vResult;
     155}
     156
     157// cross product between 2 vectors
     158CVector3 CrossProduct(CVector3 vVector1, CVector3 vVector2)
     159{
     160        CVector3 vCross;       
     161        vCross.x = ((vVector1.y * vVector2.z) - (vVector1.z * vVector2.y));
     162        vCross.y = ((vVector1.z * vVector2.x) - (vVector1.x * vVector2.z));
     163        vCross.z = ((vVector1.x * vVector2.y) - (vVector1.y * vVector2.x));
     164        return vCross; 
     165}
     166
     167// calculate the normal of a vector
     168CVector3 NormalizeVector(CVector3 vNormal)
     169{
     170        double Magnitude;
     171        Magnitude = Mag(vNormal);       
     172        vNormal.x /= (float)Magnitude; 
     173        vNormal.y /= (float)Magnitude; 
     174        vNormal.z /= (float)Magnitude; 
     175
     176        return vNormal;
     177}
     178
     179
    113180#endif /* _ABSTRACT_MODEL_H */
Note: See TracChangeset for help on using the changeset viewer.