# [c#][dx9] Catmull-Rom issue.

This topic is 3082 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hopefully anyone using catmull rom splines should be able to answer this question. I have the following code for the spline below. My control points are : V0 (207.3548, 307.411133, 0.0) V1 (216.346, 307.809326, 0.0) V2 (220.2217, 307.9812, 1.026721) V3 (276.0361, 310.452759, 2.12494135) And the weights are: Weights 0, 0.257406383, 0.51481276, 0.77221918, 1 But the points I receive are: x y z 216.3460228 307.8093283 0.0000 216.4302368 307.8130493 0.1897 215.3150024 307.7636719 0.4618 215.9187622 307.7904053 0.7674 220.2271271 307.9812012 1.0267 The part that I find confusing is why the x value reduces then increases which should not be the case. I have tried a few control points and most times it works but sometimes is doesn't. Could someone please input these values into their equation and check they get the same. Or see where I am going wrong. Thanks
[        public Vector3 D3DXVec3CatmullRom(Vector3 pV0, Vector3 pV1, Vector3 pV2, Vector3 pV3, double s)
{
Vector3 Vector = new Vector3(0,0,0);

Vector = 0.5f * (    (2 * pV1) +
(-pV0 + pV2) *((float)s) +
(2 * pV0 - 5 * pV1 + 4 * pV2 - pV3) *((float) Math.Pow( s,2)) +
(-pV0 + 3 * pV1 - 3 * pV2 + pV3) *((float) Math.Pow( s,3))
);

return Vector;
}]


##### Share on other sites
Quote:
 Original post by Carbon_PhDThe part that I find confusing is why the x value reduces then increases which should not be the case.

What makes you think that? [smile]

It's an incorrect assumption on your part. Try playing around with this and see what happens when you create a curve similar to the one you have above.

##### Share on other sites
Maybe the image below will help explain. I understand how the catmull roms work (i think) and the line in question is the horizontal red one. When ever it crosses over another line the z value is increased slightly.

So for that line there are 2 end points at the ends of each line, 4 crossover points and 2 more dummy nodes that are close to the endpoints and share the same line equation.

I am just looking at the left hand edge where the first point is the dummy point, the second is the endpoint of the line, the third the intersection and the 4th the next intersection.

Its a simple curve and i was expecting quite simple interpolation between the two ponts but instead is goes back on its self and then all of a sudden jumps from 215 to 20 (in x). Which leads me to believe that I have not coded it right?
A similar problem occurs at the third crossover point as well?!

1. 1
2. 2
Rutin
20
3. 3
4. 4
frob
14
5. 5

• 10
• 9
• 16
• 9
• 9
• ### Forum Statistics

• Total Topics
632594
• Total Posts
3007304

×