kill(all)$

maxima : appendix weight on triangle ( =centroid),matrix ,version 1.0
peter.vlasschaert@gmail.com,17/09/2020

load packages, option
==================

load(lrats)$ ratprint:false$

ref :consult , Denis Constales, prof UGent.

1e) matrix (=right triangle),figure 1
==========================

MA: matrix(
 [A1x,B1x,C1x], 
 [A1y,B1y,C1y], 
 [A1z,B1z,C1z]
);

→ use coordinates:right triangle

p1:[A1x=1,A1y=0,B1x=0,B1y=1,C1x=0,C1y=0,
A1z=1,B1z=1,C1z=1];

MAf:lratsubst(p1,matrix(
 [A1x,B1x,C1x], 
 [A1y,B1y,C1y], 
 [A1z,B1z,C1z]
));

2e)  matrix (=general triangle),figure 1
=============================

MB: matrix(
 [Ax,Bx,Cx], 
 [Ay,By,Cy], 
 [Az,Bz,Cz]
);

p2:[Az=1,Bz=1,Cz=1];

MBf:lratsubst(p2,MB);

3e) transformation : matrix
====================
M = MAf*(MB)^(-1)

M:ratsimp(MAf.invert(MB));

4e) centroid : G,G1
===============

because :2 dimensional

p1:[Gz=1,G1z=1];

v:lratsubst(p1, matrix(
 [Gx], 
 [Gy], 
 [Gz]
));
v1:lratsubst(p1, matrix(
 [G1x], 
 [G1y], 
 [G1z]
));

rem : default option for general evaluation.

simp;

simp:false; /*block :realtime,evaluation */

p4c1:v1=(G1x*col(MAf,1)+(G1y)*col(MAf,2)+(1- G1x-G1y)*col(MAf,3));

simp:true; /*remove : the block,for evaluation */

p4c1a:p4c1;

use : A+B+C =1,{A,B,C},weight of points
--------------------------------------------------------

reason : G1[x] => reason :exact (unit x value) →replace by the weight : A
               G1[y] => reason :exact (unit y value) →replace by the weight : B

p4c2:[G1x=A,G1y=B];

p4c3:A+B+C=1; /*constraint */

p4c3:lhs(p4c1)=lratsubst(p4c2,rhs(p4c1));

find : G ,coordinates ,see figure 1
=========================
use :p3g

p4a:v=ratsimp(M.rhs(p4c3));

example : A =1/2,B=1/4 ,C=1-3/4=1/4 ( = weight 'point')
===========================================

p4c4:[A=1/2,B=1/4];

calculation :need coordinates , general triangle,figure 1
----------------

p4c6:lratsubst(p4c4,p4a);

p4c6a:lhs(p4c6)[1][1]=rhs(p4c6)[1][1];
p4c6b:lhs(p4c6)[2][1]=rhs(p4c6)[2][1];

p4c7:[Ax=1,Ay=0,Bx=0,By=1,Cx=0,Cy=0];

p4c7a:append(p4c7,p2);

check :identity projection ( = both triangles are the same)
=============================================

p5a:lhs(p4c6)[1][1]=lratsubst(p4c7a,rhs(p4c6)[1][1]);
p5b:lhs(p4c6)[2][1]=lratsubst(p4c7a,rhs(p4c6)[2][1]);
p5c:lhs(p4c6)[3][1]=lratsubst(p4c7a,rhs(p4c6)[3][1]);

C=1-rhs(p5a)-rhs(p5b);