Changeset 3355 in orxonox.OLD for orxonox/branches/parenting/src/curve.cc
- Timestamp:
- Jan 6, 2005, 1:52:47 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/parenting/src/curve.cc
r3351 r3355 164 164 \param t The position on the Curve (0<=t<=1) 165 165 \return the Position on the Path 166 \todo implement nodeCount 0,1,2,3167 166 */ 168 167 Vector BezierCurve::calcPos(float t) 169 168 { 170 if (nodeCount < 4)171 {172 // if (verbose >= 1)173 // printf ("Please define at least 4 nodes, until now you have only defined %i.\n", nodeCount);174 return Vector(0,0,0);175 }176 PathNode* tmpNode = firstNode;177 169 Vector ret = Vector(0.0,0.0,0.0); 178 double factor = pow(1.0-t,nodeCount-1); 179 while(tmpNode) 180 { 181 ret.x += tmpNode->factor * factor * tmpNode->position.x; 182 ret.y += tmpNode->factor * factor * tmpNode->position.y; 183 ret.z += tmpNode->factor * factor * tmpNode->position.z; 184 factor *= t/(1.0-t); // same as pow but much faster. 185 186 tmpNode = tmpNode->next; 187 } 170 if (this->nodeCount >= 3) 171 { 172 PathNode* tmpNode = this->firstNode; 173 double factor = pow(1.0-t,nodeCount-1); 174 while(tmpNode) 175 { 176 ret.x += tmpNode->factor * factor * tmpNode->position.x; 177 ret.y += tmpNode->factor * factor * tmpNode->position.y; 178 ret.z += tmpNode->factor * factor * tmpNode->position.z; 179 factor *= t/(1.0-t); // same as pow but much faster. 180 181 tmpNode = tmpNode->next; 182 } 183 } 184 else if (nodeCount == 2) 185 { 186 ret = this->firstNode->position *(1.0-t); 187 ret = ret + this->firstNode->next->position * t; 188 } 189 else if (nodeCount == 1) 190 ret = this->firstNode->position; 188 191 return ret; 189 192 }
Note: See TracChangeset
for help on using the changeset viewer.