Original Post
Hello guys! I'm working on a project where I'm going to need paths, like splines, circles, lines, etc. So I figured I would have a Path-class which can contain multiple sub-paths (one spline leading to one straight line and ends with a half circle", and from that class I can get coordinates for a position (0.0 - 1.0). Example: (2D)
CPath MyPath;
MyPath.Append(new CLine(0.0, 0.0, 10.0, 10.0)); // p1x, p1y, p2x, p2y
MyPath.Append(new CBezier(10.0, 10.0, 15.0, 15.0, 20.0, 10.0)); // p1x, p1y, p2x, p2y, p3x, p3y
MyPath.Append(new CArc(20.0, 15.0, 5.0, PI / 2.0, -PI / 2.0)); // centerx, centery, radius, startangle, endangle
Pos = MyPath.GetPosition(0.5); // would probably be on the Bezier curve
It would look something like this:
_ |
_/ \_/
/
/
So, my question #1 is: how would you implement this? If I know the length of each "sub-path" (ie, the line, bezier graph and the arc) it would be pretty easy to calculate which sub-path the position refers to, but how would I get the position on that sub-path? (My head is blocked I'm afraid). EDIT: Impossible to get the ASCII-art correct...