barytocartUVL

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 1.0, Creation date: 2012-08-04, Last change: 2025-09-14

converts a 2d Barycentric [u,v] vertex list into a 3D Cartesian coordinate list [x, y, z]

Description

Expecting all vertices in the plane of a triangle p1p2p3, the coordinates of the vertices can be formulated as p1 + u*(p2-p1) + v* (p3-p1). The Barycentric coordinates are [u v].
Both procedures can be used to solve 3D problems in 2D

barytocartUVL is unable to detect the distance to the plane!


See Also: carttobaryVL

Example Illustration

 missing image of barytocartUVL(p1,p2,p3,UVL)

Syntax

VL=barytocartUVL(p1,p2,p3,UVL)

Input Parameter

p1: Point 1 of the triangle
p2: Point 2 of the triangle
p3: Point 3 of the triangle
UVL: Barycentric vertex list, all points in plane

Output Parameter

VL: n x 3 list with [x y z]

Examples


barytocartUVL([0 0 0],[ 0 10 10],[0 0 20],[0 0.5])




Copyright 2012-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, barytocartUVL, converts 2D Barycentric coordinates into 3D Cartesian coordinates. It is designed to work with points in the plane of a triangle defined by three vertices, p1, p2, and p3.

Input Parameters

Output

Algorithm Steps

  1. Calculate the number of Barycentric coordinates, n, from the size of UVL.
  2. Initialize an n x 3 matrix VL with zeros to store the resulting Cartesian coordinates.
  3. Compute the vectors v0 and v1 as the differences between the triangle vertices: v0 = p3 - p1 and v1 = p2 - p1.
  4. For each Barycentric coordinate [u, v] in UVL, calculate the corresponding Cartesian coordinate using the formula: VL(i,1:3) = p1 + u*v0 + v*v1.

Visualization (Optional)

If no output is requested (i.e., nargout == 0), the function will visualize the triangle and the points:

Algorithm explaination created using ChatGPT on 2025-08-19 07:42. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21