Public Group

Bezier Curve to Triangle Strip

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

Recommended Posts

So, I don't normally do this but since it's been about 3 hours since I posted my other thread and no one has even LOOKED at it (has 0 views), I decided to repost my question here.

Basically, I have a vector2 array of points that are currently being drawn as a line list. But I want to add thickness to them. The only way I see myself being able to do this is creating a curve "parallel" to the first curve in which each point is equidistant from the opposing point. Then, I'd convert the 2 curves into a triangle list by alternating through the points.

My problem is in calculating a parallel curve.

So does anyone know how to do this OR do you know how to add thickness to a line in XNA? Thanks in advance. ^^

Share on other sites
So I think I got a way to do it... since a curve is technically a bunch of straight lines, you could add thickness by adding points above and bellow a point along a perpendicular line. My function isn't working correctly. Anyone know why?

public static Vector2 perpendicularPoint(Vector2 p1, Vector2 p2) { float m = (p1.Y - p2.Y) / (p1.X - p2.Y); float b = p1.Y - ((1 / m) * p1.X); Vector2 point = new Vector2(0, ; if (point == p1) { point = new Vector2(-1, b + (-1 / m)); } return point; } ///And this function is used to calculate the exact points. You plug in a point, a point on the perpendicular line, and a distance to travel. public static Vector2 distanceToPoint(Vector2 MoveFrom, Vector2 Reference, int toTravel) { //get distance //sqrt( (X2 - X1)^2 + (y2 - y1)^2 ) = d float d = (int)Math.Sqrt((Math.Pow((MoveFrom.X - Reference.X), 2) + Math.Pow((MoveFrom.Y - Reference.Y), 2))); //Get X and Y differences float difX = MoveFrom.X - Reference.X; float difY = MoveFrom.Y - Reference.Y; //Get Ratio float ratio = ((float)toTravel / d); //Apply ratio to differences difX = difX * ratio; difY = difY * ratio; //Return new Vector return new Vector2(MoveFrom.X + difX, MoveFrom.Y + difY); } 

Share on other sites
Cross posting is not a good idea. I posted in your other thread.

And I said that "isn't working correctly" doesn't mean ANYTHING (a sticky should be made on this thing, it's pretty annoying to always ask for more info)

Anyways: post an image to make our task easier.

Share on other sites

Cross posting is not a good idea. I posted in your other thread.

And I said that "isn't working correctly" doesn't mean ANYTHING (a sticky should be made on this thing, it's pretty annoying to always ask for more info)

Anyways: post an image to make our task easier.

As the curve approaches the middle of the screen, the thickness decreases.

Share on other sites
perpendicular vector:

xp = y
yp = -x

Share on other sites

perpendicular vector:

xp = y
yp = -x

That doesn't work. It doesn't even incorporate the second point. How can you calculate a perpendicular point with just one point o.O

Share on other sites
I wrote vector, not point. I meant direction.

Share on other sites

I wrote vector, not point. I meant direction.

Even so, you can't calculate direction with one point.

Here, what is xp ,yp, x, and y?

Cause the way I see it is xp, yp are the x and y direction of the vector and x and y are 1 points coords...

Share on other sites

[quote name='szecs' timestamp='1298215675' post='4776689']
I wrote vector, not point. I meant direction.

Even so, you can't calculate direction with one point.

Here, what is xp ,yp, x, and y?

Cause the way I see it is xp, yp are the x and y direction of the vector and x and y are 1 points coords...
[/quote]
szecs is right about using the perpendicular vector. The vector that this vector is perpendicular to would be the unit-length direction (tangent) vector at the specified point on the spline, which can be computed using some simple vector math if the spline is represented as a series of line segments, or can be computed directly from the spline representation.

Share on other sites

[quote name='slynk' timestamp='1298218986' post='4776705']
[quote name='szecs' timestamp='1298215675' post='4776689']
I wrote vector, not point. I meant direction.

Even so, you can't calculate direction with one point.

Here, what is xp ,yp, x, and y?

Cause the way I see it is xp, yp are the x and y direction of the vector and x and y are 1 points coords...
[/quote]
szecs is right about using the perpendicular vector. The vector that this vector is perpendicular to would be the unit-length direction (tangent) vector at the specified point on the spline, which can be computed using some simple vector math if the spline is represented as a series of line segments, or can be computed directly from the spline representation.
[/quote]

Ohhhhhhh.... is X, Y supposed to be the direction of the line? And xp, yp is the perpendicular direction? That would be where my confusion arose. I could get how you can calculate a perpendicular direction without two points representing the line XD.

Also, does my distance function look right?

I was trying to make a function that give two points and a distance, would move from the starting point a certain distance. I guess I'll switch it to a point and a directional vector instead.

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

• 32
• 13
• 10
• 11
• 9
• Forum Statistics

• Total Topics
632558
• Total Posts
3007077

×