Skip to content

Conversation

@ntoussaint
Copy link

@ntoussaint ntoussaint commented Oct 18, 2023

Barycentric coordinate calculation

I seem to have found a problem in the barycentric coordinate calculation.

The original implementation was giving me incorrect coordinates. This seemed to not influence the "distance", and therefore might have been remained overlooked.

The correction is simple and is not adding computational time.

The calculation originates from this math-stackexchange comment

Let $\overrightarrow{u} = b - a$, $\overrightarrow{v} = c - a$, $\overrightarrow{w} = p - a$ and $\overrightarrow{n} = \overrightarrow{u} \times \overrightarrow{v}$. The barycentric coordinates of $p'$, the projection of $p$ onto the plane $(a,b,c)$ are therefore:

$$ \gamma = [(\overrightarrow{u} \times \overrightarrow{w} ) \cdot \overrightarrow{n} ] / | \overrightarrow{n} |^2 $$

$$ \beta = [(\overrightarrow{w} \times \overrightarrow{v} ) \cdot \overrightarrow{n} ] / | \overrightarrow{n} |^2 $$

$$ \alpha = 1 - \beta - \gamma$$

The coordinates of the projected point is

$$ p' = \alpha a+ \beta b + \gamma c $$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant