funsCartBary: Converts of a point in Cartesian coordinates to Barycentric...

funsCartBaryR 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 (\insertCiteweisstein-barycentric;textualpcds).

Usage

cart2bary(P, tri)

bary2cart(P, tri)

Arguments

P

A 2D point for cart2bary, and a vector of three numeric entries for bary2cart.

tri

A 3 \times 2 matrix with each row representing a vertex of the triangle.

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

\insertAllCited

Examples

## Not run: 
#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)

## End(Not run)

## Not run: 
#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)

## End(Not run)


elvanceyhan/pcds documentation built on June 29, 2023, 8:12 a.m.