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
- p1: A 3D point representing the first vertex of the triangle.
- p2: A 3D point representing the second vertex of the triangle.
- p3: A 3D point representing the third vertex of the triangle.
- UVL: A list of Barycentric coordinates, where each entry is a pair [u, v] representing a point in the plane of the triangle.
Output
- VL: An n x 3 list of Cartesian coordinates [x, y, z] corresponding to the Barycentric coordinates in
UVL
.
Algorithm Steps
- Calculate the number of Barycentric coordinates,
n
, from the size of UVL
.
- Initialize an n x 3 matrix
VL
with zeros to store the resulting Cartesian coordinates.
- Compute the vectors
v0
and v1
as the differences between the triangle vertices: v0 = p3 - p1
and v1 = p2 - p1
.
- 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:
- Calculate the bounding box of the triangle using
sofBB
and BBofVL
.
- Create a figure with a specific view angle using
SGfigure
and view
.
- Plot the triangle and its vertices using
CVLplot
and textVL
.
- Plot the Cartesian points from
VL
using VLplot
.
- Plot the Barycentric coordinates using
CPLplot
and PLplot
.
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