funsCartBary {pcds} | R Documentation |
Converts of a point in Cartesian coordinates to Barycentric coordinates and vice versa
Description
Two functions: cart2bary
and bary2cart
.
cart2bary
converts Cartesian coordinates of
a given point P
=(x,y)
to barycentric coordinates
(in the normalized form)
with respect to the triangle tri
=(v_1,v_2,v_3)
with vertex labeling done row-wise in tri
(i.e., row i
corresponds to vertex v_i
for i=1,2,3
).
bary2cart
converts barycentric coordinates of
the point P
=(t_1,t_2,t_3)
(not necessarily normalized) to
Cartesian coordinates according to the coordinates of the triangle, tri
.
For information on barycentric coordinates,
see (Weisstein (2019)).
Usage
cart2bary(P, tri)
bary2cart(P, tri)
Arguments
P |
A 2D point for |
tri |
A |
Value
cart2bary
returns the barycentric coordinates
of a given point P
=(x,y)
and
bary2cart
returns the Cartesian coordinates
of the point P
=(t_1,t_2,t_3)
(not necessarily normalized).
Author(s)
Elvan Ceyhan
References
Weisstein EW (2019). “Barycentric Coordinates.” From MathWorld — A Wolfram Web Resource, http://mathworld.wolfram.com/BarycentricCoordinates.html.
Examples
#Examples for cart2bary
c1<-.4; c2<-.6
A<-c(0,0); B<-c(1,0); C<-c(c1,c2);
Tr<-rbind(A,B,C)
cart2bary(A,Tr)
cart2bary(c(.3,.2),Tr)
#Examples for bary2cart
c1<-.4; c2<-.6
A<-c(0,0); B<-c(1,0); C<-c(c1,c2);
Tr<-rbind(A,B,C)
bary2cart(c(.3,.2,.5),Tr)
bary2cart(c(6,2,4),Tr)