Changeset 3015 in orxonox.OLD for orxonox/branches/bezierTrack/src
- Timestamp:
- Nov 27, 2004, 5:38:19 PM (20 years ago)
- Location:
- orxonox/branches/bezierTrack/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/bezierTrack/src/track.cc
r3014 r3015 66 66 { 67 67 return curve.calcPos (t); 68 } 69 Vector Track::getDir (float t) 70 { 71 return curve.calcDir (t); 68 72 } 69 73 -
orxonox/branches/bezierTrack/src/track.h
r3014 r3015 39 39 40 40 Vector getPos(float t); 41 Vector getDir (float t); 42 41 43 42 44 virtual void post_enter (WorldEntity* entity); // handle coordinate transition in here !!! (when dist < 0 or dist > lasttracklenght) -
orxonox/branches/bezierTrack/src/vector.cc
r3010 r3015 912 912 PathNode* tmpNode = firstNode; 913 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-1; 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 } 914 Vector ret = Vector(0.0,0.0,0.0); 915 double factor; 916 917 for (int k=0; k < nodeCount; k++) 918 { 919 factor = ncr (nodeCount, k); 920 921 for (int j=0; j<nodeCount-k; j++) 922 factor*=(1-t); 923 for (int j=0; j<k; j++) 924 factor*=t; 925 ret.x += factor * tmpNode->position.x; 926 ret.y += factor * tmpNode->position.y; 927 ret.z += factor * tmpNode->position.z; 928 929 tmpNode = tmpNode->next; 939 930 } 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; 931 return ret; 947 932 } 948 933 … … 964 949 return curvePoint; 965 950 } 951 952 953 int BezierCurve::ncr(int n, int i) 954 { 955 int ret = 1; 956 for (int k=1; k<=n; k++) 957 ret*=k; 958 for (int k=1; k<=i; k++) 959 ret/=k; 960 for (int k=1; k<=n-i; k++) 961 ret/=k; 962 963 return ret; 964 } -
orxonox/branches/bezierTrack/src/vector.h
r3010 r3015 173 173 PathNode* currentNode; 174 174 175 int ncr(int n, int i); 176 175 177 public: 176 178 BezierCurve (void);
Note: See TracChangeset
for help on using the changeset viewer.