Changeset 3348 in orxonox.OLD for orxonox/branches/parenting/src/curve.cc
- Timestamp:
- Jan 6, 2005, 3:03:54 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/parenting/src/curve.cc
r3330 r3348 24 24 #include "curve.h" 25 25 #include "matrix.h" 26 #include "debug.h" 26 27 27 28 #include <math.h> … … 113 114 114 115 // rebuilding the Curve itself 115 int k=0; 116 int binCoef = 1; 117 while(tmpNode) 118 { 119 if (k+1 < nodeCount-k) 120 binCoef *=(nodeCount-k)/(k+1); 121 else 122 binCoef /= (k+1)/(nodeCount-k); 123 ++k; 116 float k=0; 117 float n = nodeCount -1; 118 float binCoef = 1; 119 printf("n=%f\n", n); 120 while(tmpNode) 121 { 124 122 tmpNode->factor = binCoef; 125 tmpNode = tmpNode->next; 123 printf("bincoef: %f\n", binCoef); 124 if (tmpNode =tmpNode->next) 125 { 126 binCoef *=(n-k)/(k+1); 127 ++k; 128 } 126 129 } 127 130 … … 149 152 \param t The position on the Curve (0<=t<=1) 150 153 \return the Position on the Path 154 \todo implement nodeCount 0,1,2,3 151 155 */ 152 156 Vector BezierCurve::calcPos(float t) 153 157 { 154 if (nodeCount < =4)158 if (nodeCount < 4) 155 159 { 156 160 // if (verbose >= 1) … … 160 164 PathNode* tmpNode = firstNode; 161 165 Vector ret = Vector(0.0,0.0,0.0); 162 float factor = 1.0*pow(1.0-t,nodeCount); 163 while(tmpNode) 164 { 165 factor *= t/(1.0-t); // same as pow but much faster. 166 double factor = pow(1.0-t,nodeCount-1); 167 while(tmpNode) 168 { 166 169 ret.x += tmpNode->factor * factor * tmpNode->position.x; 167 170 ret.y += tmpNode->factor * factor * tmpNode->position.y; 168 171 ret.z += tmpNode->factor * factor * tmpNode->position.z; 172 factor *= t/(1.0-t); // same as pow but much faster. 169 173 170 174 tmpNode = tmpNode->next;
Note: See TracChangeset
for help on using the changeset viewer.