<p>I've tried using the classic formula of calculating barycentric coordinates.</p>
<p><a href="https://i.sstatic.net/VDSQP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/VDSQP.png" alt="enter image description here" /></a></p>
<p>When the plane on which you are projecting the texture is collinear to any of the base vectors it crashes with a division on zero error.</p>
<p>Is there any way to avoid this problem?</p>

CC BY-SA 4.0
2021-04-12T20:07:44.663Z
A work around is to add a small value to the denominator to prevent it from ever reaching zero.
pmw1234
CC BY-SA 4.0
2021-04-13T17:45:19.883Z
I've already tried it? it doesn't work, uv coordinates get bigger than the texture
BattlePie
CC BY-SA 4.0
2021-04-14T13:24:29.940Z
Make sure your basis vectors are linearly independent, the solution to barycentric coordinates using this formula is also the solution to a 2x2 linear system which can only be inverted when the basis vectors are linearly independent. Meaning that the vertices do not form a triangle.
pmw1234
<3d><uv-mapping><3dtexture>
UV coordinates calculation broken
BattlePie
# UV coordinates calculation broken

(Asked by: username_0 on 2021-04-12)

I've tried using the classic formula of calculating barycentric coordinates.

[![enter image description here](https://i.sstatic.net/VDSQP.png)](https://i.sstatic.net/VDSQP.png)

When the plane on which you are projecting the texture is collinear to any of the base vectors it crashes with a division on zero error.

Is there any way to avoid this problem?

**Tags:** 3d, uv-mapping, 3dtexture

> **Comments:**
> **username_1**: A work around is to add a small value to the denominator to prevent it from ever reaching zero.  
> **username_0**: I've already tried it? it doesn't work, uv coordinates get bigger than the texture  
> **username_1**: Make sure your basis vectors are linearly independent, the solution to barycentric coordinates using this formula is also the solution to a 2x2 linear system which can only be inverted when the basis vectors are linearly independent. Meaning that the vertices do not form a triangle.  

---

## 0 answers

