kill(all)$

maxima : intro to residue curve ( = ternary plot,load draw),version 1.0b ,part 4a
peter.vlasschaert@gmail.com,01/10/2020

reference :
========

ref1:maxima : intro to residue curve ( = ternary plot),version 1.0,part 4
        peter.vlasschaert@gmail.com,27/09/2020
ref2:maxima : using load draw for data plot ( points are lines),version 1.0
       peter.vlasschaert@gmail.com, 30/09/2020
ref 3:new: 16/09/2020:maxima : intro to residue curve ( = simple batch process),version 1.0b,part 3
Barycentric coordinate system,Affine transformation.(vector analysis).
download  (Maxima,code)       :maximaintroresiduecurvesimpbatchversion1bfinalpart3
download  (Maxima,png)        ::maximaintroresiduecurvesimpbatchversion1bfinalpart3outp
ref 4:https://courses.ms.ut.ee/MTMM.00.328/2018_fall/uploads/Main/Graphics_with_Maxima.pdf
ref 5:https://okpanico.wordpress.com/category/maxima/
        https://okpanico.wordpress.com/category/maxima/page/n/     , n =integer

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

load(draw)$load(lrats)$ ratprint:false$

scaling
----------

f:sqrt(3)/20 $/* scaling factor,*/

1e) definition :parametric plot, 'line piece'
---------------------------------------------------------

lp(a_,b_):=a_*t+b_*(1-t);

2e) coordinates ,ternary plot
----------------------------------------

horizontal:lines
============

s1x:[(k/sqrt(3))*f,((20-k)/sqrt(3))*f]$
s1y:k*f$ /* y values are fixed values */
s1:[k/sqrt(3)*t+(20-k)/sqrt(3)*(1-t),k]$
p1:makelist(makelist
  ([ev(lp(s1x[1],s1x[2]),nouns),ev(s1y,nouns)],
   t,0,1,0.1),k,0,10),float$

→  hypotenuse (1), "hypotenusa", line. (rico = +)
=====================================

s2x:[((k+10)/sqrt(3))*f,((2*k)/sqrt(3))*f]$
s2y:[(10-k)*f,0*f]$
p2:makelist(makelist
([ev(lp(s2x[1],s2x[2]),nouns),ev(lp(s2y[1],s2y[2]),nouns)],
t,0,1,0.1),k,0,10)$

→  hypotenuse (2), "hypotenusa",line.(rico = -)
====================================

s3x:[((k)/sqrt(3))*f,((2*k)/sqrt(3))*f]$
s3y:[k*f,0*f]$
p3:makelist(makelist
([ev(lp(s3x[1],s3x[2]),nouns),ev(lp(s3y[1],s3y[2]),nouns)],
t,0,1,0.1),k,0,10)$

set_draw_defaults(
    xaxis = false, xaxis_color = blue,
    xaxis_type = solid,xaxis_width = 0.01, xtics = 1,
    yaxis = false, yaxis_color = red,
    yaxis_type = solid, yaxis_width = 0.01, ytics = 1,
    dimensions = [1000,1000],
    grid = false,
    nticks = 100,
    ip_grid = [200,200],
    font = Arial,
    font_size = 20,
    line_width = 0.001,
    transparent = true
)$

wxdraw2d(
    line_width =1,
    color = green,
    point_size = 0.01, 
    points_joined = true,    
    makelist(points(p1[i]),i,1,length(p1)),
    point_size = 0.01,
    color = red,
    line_width =1,
    points_joined = true,
    makelist(points(p2[i]),i,1,length(p2)),
    point_size = 0.01,
    color = blue,
    line_width =1,
    points_joined = true,
    makelist(points(p3[i]),i,1,length(p3)),
    proportional_axes = xy   
)$

def :point 'triangle coordinates,{a,b,c}'
---------------------------------------------------

triangle coordinates,{a,b,c} →  cartesian coordinates :(x_t,y_t)

rem :reverse equations ,see :ref 3,'website'

p4a:x_t(aa_,bb_,cc):=-(2*bb_+aa_-2)/2$
p4b:y_t(aa_,bb_,cc_) :=sqrt(3)/2*aa_$

pt1:(1,0,0) ,pt2(0,1/2,1/2)

→pt1:(1,0,0)

sq1:[a=1,b=0,c=0];

p4a1:lratsubst(sq1,[x_t(a,b,c),y_t(a,b,c)]);

→pt2(0,1/2,1/2)

sq2:[a=0,b=1/2,c=1/2];

p4a2:lratsubst(sq2,[x_t(a,b,c),y_t(a,b,c)]);

p4a3:[p4a1,p4a2];

a) ternary plot :with points ,' not connected'
-----------------------------------------------------------

wxdraw2d(
    line_width =1,
    color = blue,
    point_size = 0.01, 
    points_joined = true,    
    makelist(points(p1[i]),i,1,length(p1)),
    point_size = 0.01,
    color = blue,
    line_width =1,
    points_joined = true,
    makelist(points(p2[i]),i,1,length(p2)),
    point_size = 0.01,
    color = blue,
    line_width =1,
    points_joined = true,
    makelist(points(p3[i]),i,1,length(p3)),
    point_type = filled_circle,
    point_size = 1,
    color = red,
    line_width =1,
    points_joined = false,/*here only difference,not connected */
    points(p4a3),
proportional_axes = xy /* aspectratio:'ellipse → circle ' */  
)$

b) ternary plot :with lines,'connected' .
-------------------------------------------------

wxdraw2d(        
    title = "Ternary plot {A,B,C}",       
    line_width =1,
    color = blue,
    point_size = 0.01, 
    points_joined = true,    
    makelist(points(p1[i]),i,1,length(p1)),
    point_size = 0.01,
    color = blue,
    line_width =1,
    points_joined = true,
    makelist(points(p2[i]),i,1,length(p2)),
    point_size = 0.01,
    color = blue,
    line_width =1,
    points_joined = true,
    makelist(points(p3[i]),i,1,length(p3)),
    point_type = filled_circle,
    point_size = 1,
    color = red,
    line_width =4,/* big red line */
    /* line_type =dots,*/
    points_joined = true,/*here only difference,connected */
    points(p4a3),
    /* lable the graph with use :coordinates */
    color = black,
    label(["A",p4a1[1]+0.025,p4a1[2]-0.01]),
    label(["B",0+0.025,0+0.025]),
    label(["C",1-0.025,0+0.025]),
    label(["x",1/2+0.025,0.025]),
    xtics =false,  /* removes numbers */
    ytics =false,  /* removes numbers */ 
    /* remove the frame     */
    axis_top    = false, 
    axis_bottom = false,
    axis_left   = false,
    axis_right  = false, 
    /* end remove the frame */   
    proportional_axes = 'xy 
         ),wxplot_size=[1200,1200] $