Drawing a smooth curve between 3 points
Author Message Drawing a smooth curve between 3 points

Hi,
I would like to draw a curve connecting 3 points using
directx 9. I will appreciate any help with code in vb.net
or C#

Thanks

Sat, 02 Jul 2005 03:22:03 GMT  Drawing a smooth curve between 3 points

this will interpolate between 4 points (the formula looks the same for y and
z)

t is an number between 0 and 1 (the time factor)

float t_2 = t * t;
float t_3 = t_2 * t;

FinalVerts->position.x = Frame0Verts->position.x * (-0.5f * t_3 + t_2 - 0.5f
* t) +
Frame1Verts->position.x * (1.5f * t_3 + -2.5f * t_2 + 1) +
Frame2Verts->position.x * (-1.5f * t_3 + 2 * t_2 + 0.5 * t) +
Frame3Verts->position.x * (0.5f * t_3 - 0.5 * t_2);

Quote:
> Hi,
> I would like to draw a curve connecting 3 points using
> directx 9. I will appreciate any help with code in vb.net
> or C#

> Thanks

Mon, 04 Jul 2005 21:38:58 GMT  Drawing a smooth curve between 3 points

Hi,

There are many solutions. Someone can use a Lagrange interpolation, someone can use the Newton's
formula:

y  = (x-x1)(x-x2) y3 /( (x3-x1)(x3-x2) )
+
y1 (x-x2) (x-x3)  /( (x1-x2)(x1-x3) )
+
(x-x1) y2 (x-x3) / ((x2-x1)(x2-x3))
' mathematical notation.

It is easily expandable to n points, but that easily become chaotic (with large oscillations).

The Lagrange's formula is a little bit more stable, but here, only valid for 3 point"s:

y= a0 + a1*x  + a2*x^2
' vb/vba notation.

If we assume the three (known) points are at x=-1, x=0 and x=1, with values yn, y0 and y1, then
a0= y0
a2= 0.5*((y1-y0)+(yn-y0))
a1=0.5*((y1-y0)-(yn-y0))

You can also use a Hermite's Interpollation, if you know points and tangeant (rather than just
points). That insure a continuity of the tangeant of the curve. DirectX can help you, this time,
since it supplies many functions like D3DXVec2Hermite (see help file).

Hoping it may help,
Vanderghast, Access MVP

Quote:

> Hi,
> I would like to draw a curve connecting 3 points using
> directx 9. I will appreciate any help with code in vb.net
> or C#

> Thanks

Mon, 11 Jul 2005 06:16:05 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages