<p>You can use barycentric coordinates to calculate points inside the triangle with a determinate value for uv.</p>

<p>The process is easy =></p>

<p>Let's say that the UV coordinates of each vertex of the triangle are:</p>

<p>vertex 0 => u0,v0</p>

<p>vertex 1 => u1,v1</p>

<p>vertex 2 => u2,v2</p>

<p>A point inside the triangle has UV coordinates value expressed in function of its barycentric coordinates:</p>

<p>u coord = p0 * u0 + p1 * u1 + p2 * u2</p>

<p>v coord = p0 * v0 + p1 * v1 + p2 * v2</p>

<p>where p0,p1,p2 are the barycentric coordinates of this point.</p>

<p>As barycentric coordinates has the property:</p>

<p>p0 + p1 + p2 = 1</p>

<p>you can calculate the barycentric coordinates of a point with a specific value for UV just by solving these equations. I mean, for example, you want to know which point inside the triangle has</p>

<p>UV = (1,2)</p>

<p>To calculate such a point just do:</p>

<p>1 = p0 * u0 + p1 * u1 + p2 * u2</p>

<p>2 = p0 * v0 + p1 * v1 + p2 * v2</p>

<p>p0 + p1 + p2 = 1</p>

<p>as you know the values for (u0,v0), (u1,v1) and (u2,v2),  you can easily calculate the barycentric coordinates of this point, (p0, p1, p2).</p>

<p>Once you have the barycentric coordinates, you can calculate the coordinates (px,py,pz) of the point:</p>

<p>(px,py,pz) = p0 * vertex0 coordinates + p1 * vertex 1 coordinates + p2 * vertex 2 coordinates  </p>

CC BY-SA 3.0
2018-04-09T13:51:09.363Z
Thanks. This really helped me, barycentric coordinates, of course! ISimply use the UVs derived from the min/max of the triangles UV, and you get a regular grid over the triangle. Then simply intersect and done!
Intrins
CC BY-SA 3.0
2018-04-07T08:04:28.363Z
2018-04-07T08:04:28.363Z
Jordi Cruzado
<p>I'm looking into a problem that first occured very trivial to me, but i got stuck and it's becoming a major issue right now. I'd like to subdivide a triangle by its given UVs, e.g. if the UVs are going from -n...+m or if they are greater than 1. So for example if i have a U coordinate from -1.5 ... 4 i'd like to subdivide at -1.0, 0.0, 1.0, 2.0, 3.0. Here's a visualization of the polygons that can be generated. Triangulation is trivial of course. </p>

<p><a href="https://i.sstatic.net/afHHS.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/afHHS.jpg" alt="This is how it renders with a UV texture"></a></p>

<p>My idea was to subdivide each edge separately for U and V and then find intersections and use these intersections to spawn triangles. However, i can't even find the rule how each line is constructed. Maybe someone can shed some light?</p>

<p>Thanks!</p>

CC BY-SA 3.0
2018-04-06T02:25:36.347Z
It might be helpful if you think about how the tangent and bitangent are literally the vectors that the u and v axis travel in across the triangle.
Alan Wolfe
<geometry><triangulation>
Subdivide a triangle along its UVs
Intrins
# Subdivide a triangle along its UVs

(Asked by: username_0 on 2018-04-05)

I'm looking into a problem that first occured very trivial to me, but i got stuck and it's becoming a major issue right now. I'd like to subdivide a triangle by its given UVs, e.g. if the UVs are going from -n...+m or if they are greater than 1. So for example if i have a U coordinate from -1.5 ... 4 i'd like to subdivide at -1.0, 0.0, 1.0, 2.0, 3.0. Here's a visualization of the polygons that can be generated. Triangulation is trivial of course.

[![This is how it renders with a UV texture](https://i.sstatic.net/afHHS.jpg)](https://i.sstatic.net/afHHS.jpg)

My idea was to subdivide each edge separately for U and V and then find intersections and use these intersections to spawn triangles. However, i can't even find the rule how each line is constructed. Maybe someone can shed some light?

Thanks!

**Tags:** geometry, triangulation

> **Comments:**
> **username_1**: It might be helpful if you think about how the tangent and bitangent are literally the vectors that the u and v axis travel in across the triangle.  

---

## 1 answers

### Answer by username_2 on 2018-04-07. Score: 1 | Accepted answer

You can use barycentric coordinates to calculate points inside the triangle with a determinate value for uv.

The process is easy =>

Let's say that the UV coordinates of each vertex of the triangle are:

vertex 0 => u0,v0

vertex 1 => u1,v1

vertex 2 => u2,v2

A point inside the triangle has UV coordinates value expressed in function of its barycentric coordinates:

u coord = p0 \* u0 + p1 \* u1 + p2 \* u2

v coord = p0 \* v0 + p1 \* v1 + p2 \* v2

where p0,p1,p2 are the barycentric coordinates of this point.

As barycentric coordinates has the property:

p0 + p1 + p2 = 1

you can calculate the barycentric coordinates of a point with a specific value for UV just by solving these equations. I mean, for example, you want to know which point inside the triangle has

UV = (1,2)

To calculate such a point just do:

1 = p0 \* u0 + p1 \* u1 + p2 \* u2

2 = p0 \* v0 + p1 \* v1 + p2 \* v2

p0 + p1 + p2 = 1

as you know the values for (u0,v0), (u1,v1) and (u2,v2), you can easily calculate the barycentric coordinates of this point, (p0, p1, p2).

Once you have the barycentric coordinates, you can calculate the coordinates (px,py,pz) of the point:

(px,py,pz) = p0 \* vertex0 coordinates + p1 \* vertex 1 coordinates + p2 \* vertex 2 coordinates

> **Comments:**
> **username_0**: Thanks. This really helped me, barycentric coordinates, of course! ISimply use the UVs derived from the min/max of the triangles UV, and you get a regular grid over the triangle. Then simply intersect and done!  

---

