kill(all)$

maxima: affine combinations (=center of mass) and vector analysis.
peter.vlasschaert@gmail.com,28/09/2020

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

load(lrats)$ ratprint:false$

Affine combination
===============

a)  affine combination,"see figure 1"
============================

vec(a)  →  0A   (ax,ay)
vec(b)  →  0B   (bx,by)
vec(c)  →  0C   (cx,cy)
--------------------------------------------------------------------------------------------------------------------------
vec(c) = (1-λ)*vec(a) + λ*vec(b)    (1)

p1a:cx = (1-λ)*ax + λ*bx;
p1b:cy = (1-λ)*ay + λ*by;

values : λ=0,λ=1
-----------------------

p1a1:subst([λ=0],p1a);
p1b1:subst([λ=0],p1b);

result : vec(c) = vec(a)

p1a2:subst([λ=1],p1a);
p1b2:subst([λ=1],p1b);

result : vec(c) = vec(b)

midpoint  ( = λ =1/2)
----------------------------

p1a3:lhs(p1a)=factorsum(subst([λ=1/2],rhs(p1a)));
p1b3:lhs(p1b)=factorsum(subst([λ=1/2],rhs(p1b)));

result : vec(c) =1/2*(vec(a) +vec(b))

1e) vec(v) =(vx,vy); ? ,  CA , see :direction
-----------------------------------------
CA  = vec(a)  - vec(c)

p2a:vx = γ*(ax-bx);
p2b:vy = γ*(ay-by);

2e) vec(w) =(vx,vy); ? ,  CB , see :direction
-----------------------------------------
CB  = vec(b)  - vec(c)

p3a:wx=(1-γ)*(bx-ax);
p3b:wy=(1-γ)*(by-ay);

3e)  vec(AB) = vec(B) - vec(A)
-------------------------------------------

p4a:expand(p3a-p2a);
p4b:expand(p3b-p2b);

because orgin can be choose arbitrary
------------------------------------------------------
C = (1-λ)*A + λ*B,allowed for the points also.

points A,B,C  , β =real number

p5:C=β*A+(1-β)*B;

p5a:β = l_i/(l_i+k_i);

p5a1:1-lhs(p5a)=ratsimp(1-rhs(p5a));

p5a2:p5a+p5a1;

p5a3:combine(p5a2);

p5b:lratsubst([p5a1],p5);

p5b1:expand(p5b);

center of mass ( G =G(Gx,Gy))
=======================

1e) vec(d) =D
-------------------

p6:D = A + ((L_3)/(L_3+K_3))*(C-A);

p6a:expand(p6);

m1:ratio : A/C

p6a1:ratcoef(rhs(p6a),A);/*coef :A */

p6a2:ratcoef(rhs(p6a),C);/*coef :C */

p6a3:p6a1/p6a2;

2e) vec(e) =E
--------------------

p7:E = B + ((L_2)/(L_2+K_2))*(C-B);

p7a:expand(p7);

3e) vec(g) =G
-------------------

p8a:G = λ*B +(1-λ)*D;
p8b:G = κ*A +(1-κ)*E;

4e) combination {1e,2e,3e}
---------------------------------------

p9a:lratsubst(p6a,p8a);
p9b:expand(lratsubst(p7a,p8b));

 m2:ratio : A/C
--------------------
use :p9b

p9b1:ratcoef(rhs(p9b),A);/*coef :A */
p9b2:ratcoef(rhs(p9b),C);/*coef :C */
p9b3:p9b1/p9b2;

result:m1=m2
-------------------

p10:p6a3=p9b3;

p10a:solve(p10,κ)[1];

solve : G
------------

p10b:lratsubst(p10a,p9b);

p10b1:expand(p10b);

coordinates: G (Gx,Gy)
==================

find :Gx
-----------

p11a:[C=Cx,B=Bx,A=Ax,G=Gx];

p11b:lratsubst(p11a,p10b1),expand;

find :Gy
-----------

p12a:[C=Cy,B=By,A=Ay,G=Gy];

p12b:lratsubst(p12a,p10b1),expand;

example :
=======
given:L_2=2,K_2=1,L_3=3,K_3=2,see : Figure.3
given : coordinates A(Ax,Ay),B(Bx,By),C(Cx,Cy) ' position vector'

p13:lratsubst([L_2=2,K_2=1,L_3=3,K_3=2],L_2*L_3+K_2*L_3+K_3*L_2);

p13a:lratsubst([L_2=2,K_2=1,L_3=3,K_3=2],p10b1),expand;

p13a1:ratsimp(p13a);

What about  L1,K1
--------------------------

result : point F , C=0 

→   line  AB with point inside F ?
==========================

1e) step  :line AC  ,inside  E, L_3=3,K_3=2
-----------------------------------

p14a:ratsimp(1/2*subst([B=0],rhs(p13a)));

p14b:expand(%);

p14c1:ratcoef(p14b,A)*A;
p14c2:ratcoef(p14b,C)*C;

r1: p14c1=p14c2;

r1a:solve(r1,A);

→ A = L_3/K_3*C, L_3=3,K_3=2

2e) step  :line,AB  ,inside  E, L_1=?,K_1=?
-----------------------------------

p15a:subst([C=0],rhs(p13a));

p15a1:ratcoef(p15a,B)*B;
p15a2:ratcoef(p15a,A)*A;

r2:p15a1=p15a2;

r2a:solve(r2,A);

r2b:lratsubst([A=AF,B=FB],r2a);

→, L_1=?,K_1 =?

p16a:AF+FB = AB; 

p16b:[L_2=2,K_2=1,L_3=3,K_3=2];

p16c:AB = denom(rhs(p13a1))-sum(rhs(p16b[i]),i,1,length(p16b));

p16d:lratsubst([p16c,r2b[1]],p16a);

p16e:solve(p16d,FB);

p16f:lratsubst([p16e[1],p16c],r2b[1]);

result :example
---------------------

s1:L_1=rhs(p16e[1]);
s2:K_1=rhs(p16f);

s3:s1+s2;

check :

is(rhs(p16c)=rhs(s3));