Create polyline with triangles

Started by
5 comments, last by Oluseyi 8 years, 8 months ago

Hello,

i need to create polyline using Triangles. I got points which lead through center of polyline. I need to generate vertexes and uv's for it. I'v got many problems with proper uvs on curves. Is there any algorithm available online for it?

sorry for my poor english.

Advertisement

I'm confused. Per my understanding, a polyline is a series of connected line segments—a polygonal chain. It can exist in 3D space, but it does not intrinsically define any surface, let alone volume. To want to make one out of triangles them strikes me as impossible, nonsensical (in the literal, non-disparaging sense). I'm sure this is a communication breakdown, so can you elaborate some more on what exactly you are trying to say?

I get the sense the OP wants to extrude the polyline into a strip or maybe a solid from it.

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!

Hello.

it is possibly that i write it incorrect and you can't understand me. Here I created image showing what i trying to do:

polyline.jpg

I got red dots as polyline points. It is easy to create line through this dots. But i need to create polyline with width so I need to create it using triangles.But when i directly create it using only right vector i got errors on curves. Is there any algoritmic way to find vertex points for green triangles?

Look e.g. VASE. You can also find it in the source code of any open (S)VG renderer like NanoVG or ShivaVG, although extracting the needed bits of code requires a bit of digging.

Have a read at the bottom of this post it makes a tube from start point(3D) to endPoint.

Hello.

it is possibly that i write it incorrect and you can't understand me. Here I created image showing what i trying to do:

polyline.jpg

I got red dots as polyline points. It is easy to create line through this dots. But i need to create polyline with width so I need to create it using triangles.But when i directly create it using only right vector i got errors on curves. Is there any algoritmic way to find vertex points for green triangles?

Ah, I see what you mean. Is this a 2D strip or a full 3D "tube"? I'll tackle the 2D solution now, and then we can extrapolate to 3D as necessary.

The key is that the red points define a line through the center of your strip, and that at each joint the red point is the center of a cross-cutting line whose adjacent angle is precisely half the deflection between the segments. So, starting from the left of your diagram and numbering the red points p1, p2, p3 and p4:

  • at p1 there is no previous segment, so our strip's ends are perpendicular to the vector <p2 - p1>;
  • at p2 the cross section is at an angle relative to <p2 - p1> that is precisely half the angle between <p2 - p1> and <p2 - p3>;
  • at p3 we have no next segment, so our strip's ends are again perpendicular to the vector, this tome <p3 - p2>.

Remember that perpendicular lines have slopes that are the negatives of each other.

Using the above, you should be able to generate the points in your strip. Be careful in your algorithm to maintain the correct vertex order. I'll check back in a couple of days to see how you made out.

This topic is closed to new replies.

Advertisement