Changeset 3237 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Dec 20, 2004, 1:53:52 AM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/Makefile.in
r3236 r3237 117 117 DEFS = @DEFS@ 118 118 DEPDIR = @DEPDIR@ 119 DOXYGEN = @DOXYGEN@ 120 DOXYGEN_FALSE = @DOXYGEN_FALSE@ 121 DOXYGEN_TRUE = @DOXYGEN_TRUE@ 119 122 ECHO_C = @ECHO_C@ 120 123 ECHO_N = @ECHO_N@ -
orxonox/trunk/src/collision.cc
r3231 r3237 104 104 if( (t = a->root) == NULL) return false; 105 105 106 return cc treeTrace( pa, t, ahitflags, trace, impactpoint);106 return ccTreeTrace( pa, t, ahitflags, trace, impactpoint); 107 107 } 108 108 … … 124 124 if( (tb = b->root) == NULL) return false; 125 125 126 return cc treeIterate(pa, ta, ahitflags, pb, tb, bhitflags);126 return ccTreeIterate(pa, ta, ahitflags, pb, tb, bhitflags); 127 127 } 128 128 … … 176 176 } 177 177 178 bool cc treeIterate(const Placement* pa, CCTree* ta, unsigned long* ahitflags, const Placement* pb, CCTree* tb, unsigned long* bhitflags)178 bool ccTreeIterate(const Placement* pa, CCTree* ta, unsigned long* ahitflags, const Placement* pb, CCTree* tb, unsigned long* bhitflags) 179 179 { 180 180 bool r = false; … … 203 203 else useB = ta->data.b[ib]; 204 204 205 r = r || cc treeIterate( pa, useA, ahitflags, pb, useB, bhitflags);205 r = r || ccTreeIterate( pa, useA, ahitflags, pb, useB, bhitflags); 206 206 207 207 if( tb->n == 0) break; … … 329 329 } 330 330 331 bool cc treetrace( const Placement* p, CCTree* t, unsigned long* hitflags, const Line* trace, Vector* impactpoint)331 bool ccTreeTrace( const Placement* p, CCTree* t, unsigned long* hitflags, const Line* trace, Vector* impactpoint) 332 332 { 333 333 bool r = false; … … 352 352 for (i = 0; i < t->n; i++) 353 353 { 354 r = r || cc treeTrace (p, t->data.b[i], &(hfs[i]), trace, &(ips[i]));354 r = r || ccTreeTrace (p, t->data.b[i], &(hfs[i]), trace, &(ips[i])); 355 355 } 356 356 if( r) -
orxonox/trunk/src/collision.h
r3231 r3237 52 52 int store (char* filename); 53 53 54 friend bool cc treeTrace( const Placement* p, CCTree* t, unsigned long* hitflags, const Line* trace, Vector* impactpoint);55 friend bool cc treeIterate(const Placement* pa, CCTree* ta, unsigned long* ahitflags, const Placement* pb, CCTree* tb, unsigned long* bhitflags);54 friend bool ccTreeTrace( const Placement* p, CCTree* t, unsigned long* hitflags, const Line* trace, Vector* impactpoint); 55 friend bool ccTreeIterate(const Placement* pa, CCTree* ta, unsigned long* ahitflags, const Placement* pb, CCTree* tb, unsigned long* bhitflags); 56 56 friend bool checkTrace (const Placement* pa, const CollisionCluster* a, unsigned long* ahitflags, const Line* trace, Vector* impactpoint); 57 57 friend bool checkCollision (const Placement* pa, const CollisionCluster* a, unsigned long* ahitflags, const Placement* pb, const CollisionCluster* b, unsigned long* bhitflags); -
orxonox/trunk/src/importer/framework.cc
r3211 r3237 149 149 // PRINTF(0)("rotAxis: %f, %f, %f\n", rotAxis.x, rotAxis.y, rotAxis.z, rotAngle); 150 150 151 rotAngle = angle _rad (p1, p2);151 rotAngle = angleRad (p1, p2); 152 152 rotQ = Quaternion (rotAngle, rotAxis); 153 153 rotQ = rotQ * rotQlast; -
orxonox/trunk/src/importer/vector.cc
r2932 r3237 203 203 \return the angle between the vectors in radians 204 204 */ 205 float angle _rad (const Vector& v1, const Vector& v2)205 float angleRad (const Vector& v1, const Vector& v2) 206 206 { 207 207 return acos( v1 * v2 / (v1.len() * v2.len())); … … 215 215 \return the angle between the vectors in degrees 216 216 */ 217 float angle _deg (const Vector& v1, const Vector& v2)217 float angleDeg (const Vector& v1, const Vector& v2) 218 218 { 219 219 float f; … … 243 243 244 244 /** 245 \brief calculates a look _at rotation245 \brief calculates a lookAt rotation 246 246 \param dir: the direction you want to look 247 247 \param up: specify what direction up should be … … 578 578 Vector axis = x.cross( v); 579 579 axis.normalize(); 580 float angle = angle _rad( x, v);580 float angle = angleRad( x, v); 581 581 float ca = cos(angle); 582 582 float sa = sin(angle); … … 714 714 \return the rotated vector 715 715 */ 716 Vector rotate _vector( const Vector& v, const Rotation& r)716 Vector rotateVector( const Vector& v, const Rotation& r) 717 717 { 718 718 Vector t; … … 745 745 \return the distance between the Line and the point 746 746 */ 747 float Line::distance _point (const Vector& v) const747 float Line::distancePoint (const Vector& v) const 748 748 { 749 749 Vector d = v-r; … … 761 761 Vector* fp = new Vector[2]; 762 762 Plane p = Plane (r + a.cross(l.a), r, r + a); 763 fp[1] = p.intersect _line (l);763 fp[1] = p.intersectLine (l); 764 764 p = Plane (fp[1], l.a); 765 fp[0] = p.intersect _line (*this);765 fp[0] = p.intersectLine (*this); 766 766 return fp; 767 767 } … … 783 783 { 784 784 Vector t = a + r; 785 t = rotate _vector( t, rot);786 r = rotate _vector( r, rot),785 t = rotateVector( t, rot); 786 r = rotateVector( r, rot), 787 787 a = t - r; 788 788 } … … 815 815 \param l: a line 816 816 */ 817 Vector Plane::intersect _line (const Line& l) const817 Vector Plane::intersectLine (const Line& l) const 818 818 { 819 819 if (n.x*l.a.x+n.y*l.a.y+n.z*l.a.z == 0.0) return Vector(0,0,0); … … 827 827 \return the distance between the plane and the point (can be negative) 828 828 */ 829 float Plane::distance _point (const Vector& p) const829 float Plane::distancePoint (const Vector& p) const 830 830 { 831 831 float l = n.len(); … … 839 839 \return 0 if the point is contained within the Plane, positive(negative) if the point is in the positive(negative) semi-space of the Plane 840 840 */ 841 float Plane::locate _point (const Vector& p) const841 float Plane::locatePoint (const Vector& p) const 842 842 { 843 843 return (n.dot(p) + k); 844 844 } 845 846 847 /** 848 \brief Creates a new BezierCurve 849 */ 850 BezierCurve::BezierCurve (void) 851 { 852 nodeCount = 0; 853 firstNode = new PathNode; 854 currentNode = firstNode; 855 856 firstNode->position = Vector (.0, .0, .0); 857 firstNode->number = 0; 858 firstNode->next = 0; // not sure if this really points to NULL!! 859 860 return; 861 } 862 863 /** 864 \brief Deletes a BezierCurve. 865 It does this by freeing all the space taken over from the nodes 866 */ 867 BezierCurve::~BezierCurve (void) 868 { 869 PathNode* tmpNode; 870 currentNode = firstNode; 871 while (tmpNode != 0) 872 { 873 tmpNode = currentNode; 874 currentNode = currentNode->next; 875 delete tmpNode; 876 } 877 } 878 879 /** 880 \brief adds a new Node to the bezier Curve 881 \param newNode a Vector to the position of the new node 882 */ 883 void BezierCurve::addNode(const Vector& newNode) 884 { 885 PathNode* tmpNode; 886 if (nodeCount == 0 ) 887 tmpNode = firstNode; 888 else 889 { 890 tmpNode = new PathNode; 891 currentNode = currentNode->next = tmpNode; 892 } 893 tmpNode->position = newNode; 894 tmpNode->next = 0; // not sure if this really points to NULL!! 895 tmpNode->number = (++nodeCount); 896 return; 897 } 898 899 /** 900 \brief calculates the Position on the curve 901 \param t The position on the Curve (0<=t<=1) 902 \return the Position on the Path 903 */ 904 Vector BezierCurve::calcPos(float t) 905 { 906 if (nodeCount <=4) 907 { 908 // if (verbose >= 1) 909 // printf ("Please define at least 4 nodes, until now you have only defined %i.\n", nodeCount); 910 curvePoint = Vector(0,0,0); 911 } 912 PathNode* tmpNode = firstNode; 913 914 int k,kn,nn,nkn; 915 double blend,muk,munk; 916 Vector b = Vector(0.0,0.0,0.0); 917 918 muk = 1; 919 munk = pow(1-t,(double)nodeCount); 920 921 for (k=0; k<=nodeCount; k++) { 922 nn = nodeCount; 923 kn = k; 924 nkn = nodeCount - k; 925 blend = muk * munk; 926 muk *= t; 927 munk /= (1-t); 928 while (nn >= 1) { 929 blend *= nn; 930 nn--; 931 if (kn > 1) { 932 blend /= (double)kn; 933 kn--; 934 } 935 if (nkn > 1) { 936 blend /= (double)nkn; 937 nkn--; 938 } 939 } 940 b.x += tmpNode->position.x * blend; 941 b.y += tmpNode->position.y * blend; 942 b.z += tmpNode->position.z * blend; 943 944 tmpNode = tmpNode->next; 945 } 946 return b; 947 } 948 949 Vector BezierCurve::calcDirection (float t) 950 { 951 double diff = .00000000001; 952 953 Vector diffV = ((calcPos(t+diff) - calcPos(t))/diff); 954 diffV.normalize(); 955 return diffV; 956 } 957 958 /** 959 \brief returns the Position of the point calculated on the Curve 960 \return a Vector to the calculated position 961 */ 962 Vector BezierCurve::getPos() const 963 { 964 return curvePoint; 965 } -
orxonox/trunk/src/importer/vector.h
r3224 r3237 40 40 }; 41 41 42 float angle _deg (const Vector& v1, const Vector& v2);43 float angle _rad (const Vector& v1, const Vector& v2);42 float angleDeg (const Vector& v1, const Vector& v2); 43 float angleRad (const Vector& v1, const Vector& v2); 44 44 45 45 //! Quaternion … … 98 98 99 99 //!< Apply a rotation to a vector 100 Vector rotate _vector( const Vector& v, const Rotation& r);100 Vector rotateVector( const Vector& v, const Rotation& r); 101 101 102 102 //! 3D line … … 118 118 119 119 float distance (const Line& l) const; 120 float distance _point (const Vector& v) const;120 float distancePoint (const Vector& v) const; 121 121 Vector* footpoints (const Line& l) const; 122 122 float len () const; … … 144 144 ~Plane () {} 145 145 146 Vector intersect _line (const Line& l) const;147 float distance _point (const Vector& p) const;148 float locate _point (const Vector& p) const;146 Vector intersectLine (const Line& l) const; 147 float distancePoint (const Vector& p) const; 148 float locatePoint (const Vector& p) const; 149 149 }; 150 150 151 152 153 //! Bezier Curve 154 /** 155 Class to handle bezier curves in 3-dimesnsional space 156 157 needed for the Tracking system in OrxOnoX. 158 */ 159 class BezierCurve 160 { 161 private: 162 int nodeCount; 163 Vector curvePoint; 164 165 struct PathNode 166 { 167 int number; 168 Vector position; 169 PathNode* next; 170 }; 171 172 PathNode* firstNode; 173 PathNode* currentNode; 174 175 public: 176 BezierCurve (void); 177 ~BezierCurve (void); 178 void addNode (const Vector& newNode); 179 Vector calcPos (float t); 180 Vector calcDirection (float t); 181 182 Vector getPos () const; 183 }; 184 185 186 151 187 #endif /* _VECTOR_H */
Note: See TracChangeset
for help on using the changeset viewer.