I want to rescale a projective vector. Have been using gcd on the numerators and denominators. This works in simple situations. It doesn;t work well here, admitadely the points have been just made up for the question. Square roots seem to make it mal-preform. I run into a lot of squate roots in symbolic situations. What would be a better way? I have been wondering if frontend would help?
> |
Prntmsg::boolean:=true;
Normalise_Projective_Point:=1;
ReScl::boolean:=true;
|

|
(1) |
> |
ProjLP:=overload([
proc(A::Vector[row],B::Vector[row],prnt::boolean:=Prntmsg)
description "2 projective points to create a projective line vector";
option overload;
local Vp ,gcdn,gcdd,vp ;
uses LinearAlgebra;
Vp:=CrossProduct(A,B)^%T;#print("2nd ",Vp);
if ReScl then
gcdn := gcd(gcd(numer(Vp[1]),numer(Vp[2])), numer(Vp[3]));
gcdd := gcd(gcd(denom(Vp[1]),denom(Vp[2])), denom(Vp[3]));
Vp:=simplify(Vp*gcdd/gcdn);
end if;
if Prntmsg then
print("Line vector from two projective points. " );
end if;
return Vp
end proc,
proc(A::Vector[column],B::Vector[column],prnt::boolean:=Prntmsg)
description "2 lines to get intersection projective point";
option overload;
uses LinearAlgebra;
local Vp;
Vp:=CrossProduct(A,B)^%T;
if Vp[3]<>0 and Normalise_Projective_Point<>0 then
Vp:=Vp/Vp[3];
end if;
if Prntmsg then
print("Meet of two Lines ");
end if;
return Vp
end proc
]);
|
![proc () option overload; [proc (A::(Vector[row]), B::(Vector[row]), prnt::boolean := Prntmsg) local Vp, gcdn, gcdd, vp; option overload; description "2 projective points to create a projective line vector"; Vp := LinearAlgebra:-CrossProduct(A, B)^%T; if ReScl then gcdn := gcd(gcd(numer(Vp[1]), numer(Vp[2])), numer(Vp[3])); gcdd := gcd(gcd(denom(Vp[1]), denom(Vp[2])), denom(Vp[3])); Vp := simplify(Vp*gcdd/gcdn) end if; if Prntmsg then print("Line vector from two projective points. ") end if; return Vp end proc, proc (A::(Vector[column]), B::(Vector[column]), prnt::boolean := Prntmsg) local Vp; option overload; description "2 lines to get intersection projective point"; Vp := LinearAlgebra:-CrossProduct(A, B)^%T; if Vp[3] <> 0 and Normalise_Projective_Point <> 0 then Vp := Vp/Vp[3] end if; if Prntmsg then print("Meet of two Lines ") end if; return Vp end proc] end proc](/view.aspx?sf=238303_question/4d8a13c03cd8d9fef6f824e5423948b1.gif)
|
(2) |
> |
pt1:=<a|sqrt(b^2+c^2)|1>:
pt2:=<c|sqrt(b^2+a^2)|1>:
pt3:=<f^2/sqrt(a^2+b^2)|f^2/sqrt(c^2+b^2)+sqrt(a^2+b^2)|1>:
pt4:=<b^2/sqrt(a^2+b^2)|f^2/sqrt(c^2+b^2)-sqrt(a^2+b^2)|1>:
|
](/view.aspx?sf=238303_question/9009307d7e81971d5c925fddd8d9e985.gif)
|
(3) |
](/view.aspx?sf=238303_question/adef7a5b5bd5da9517a04003ea415055.gif)
|
(4) |
](/view.aspx?sf=238303_question/ae2e9175b7c7dd7f00b3b67495f4a3d7.gif)
|
(5) |
](/view.aspx?sf=238303_question/86703a9ffa228664d8e177b48e71073b.gif)
|
(6) |
> |
pl1l2:=simplify(ProjLP(l1,l2))
|
](/view.aspx?sf=238303_question/c36ed1656283a405ff211c3c48e210f8.gif)
|
(7) |
> |
pl2l3:=simplify(ProjLP(l2,l3))
|
](/view.aspx?sf=238303_question/7ab67ebbb3dc01f9623906e70efdd6a5.gif)
|
(8) |
> |
(ProjLP(pl1l2,pl2l3));
length(%)
|

|
(9) |

|
(10) |
> |
# doing nothing seems to work better here than rescaling
|
> |
(ProjLP(pl1l2,pl2l3));
length(%)
|

|
(11) |
|
Download 2024-05-09_Q_Rescale_projective_vector.mw