1 /* written by Gosei Furuya <go.maxima@gmail.com>
2 # This program is free software; you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation; either version 2 of the License, or
5 # (at your option) any later version.
9 add_tan(_m):=block([_u:[]],_u:cross(col(_m,1),col(_m,2)),addcol(_m,_u))$
10 cross(_a,_b):=block([_u1,_v1],_u1:makelist(_a[j,1],j,1,3),_v1:makelist(_b[j,1],j,1,3),[_u1[2]*_v1[3]-_u1[3]*_v1[2],_u1[3]*_v1[1]-_u1[1]*_v1[3],_u1[1]*_v1[2]-_u1[2]*_v1[1]])$
11 matrix_element_mult:lambda([x,y],x@y)$
12 cross2(_u1,_v1):=block([_s],_s:[_u1[2]*_v1[3]-_u1[3]*_v1[2],_u1[3]*_v1[1]-_u1[1]*_v1[3],_u1[1]*_v1[2]-_u1[2]*_v1[1]])$
13 make_tan():=block([_l:[],_l1,_l2,_l3,_l4,_ll,_p,_p4,_m],
14 _l:map(lambda([x],diff(x,coords[1])),translist),
15 _l1:map(lambda([x],x^2),_l),
16 _p:ratsimp(trigsimp(apply("+",_l1))),
17 _m:matrix(1/sqrt(_p)*_l),
18 _ll:map(lambda([x],diff(x,coords[2])),translist),
20 _l4:map(lambda([x],x^2),_l3),
21 _p4:ratsimp(trigsimp(apply("+",_l4))),
22 _l2:cross2(1/sqrt(_p4)*_l3,1/sqrt(_p)*_l),
23 addrow(_m,_l2,1/sqrt(_p4)*_l3))$