|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I wrote very simple macro for my problem but I think it is another problem for
Tor. I used new trace() but I know he likes analitic solutions. The problem is:
split one angle of triangle according to given ratio and find point on opposite
edge.
Here is my solution:
#version 3.5;
#include "math.inc"
#macro Ray_Cross_Plane(P1,P2,P3,L1,L2)
#local Normal=vcross(P2-P1,P3-P1);
#local Plane=plane{Normal 0 translate P1}
trace(Plane,L1,vnormalize(L2-L1),Normal)
#end
#macro Split_Angle(PA,PO,PB,Ratio)
#local VA=PA-PO;
#local VB=PB-PO;
#local A=VAngleD(VA,VB);
#local N=vcross(VA,VB);
#local P=vaxis_rotate(VA,N,Ratio*A)+PO;
Ray_Cross_Plane(PO,P,PO+N,PA,PB)
#end
triangle{ x , 0 , Split_Angle(x,0,y,.1) pigment{color red 1} }
triangle{ y , 0 , Split_Angle(x,0,y,.1) pigment{color green 1} }
ABX
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
>
> I wrote very simple macro for my problem but I think it is another problem for
> Tor.
=)
> I used new trace() but I know he likes analitic solutions. The problem is:
> split one angle of triangle according to given ratio and find point on opposite
> edge.
> Here is my solution:
>
> #version 3.5;
> #include "math.inc"
>
> #macro Ray_Cross_Plane(P1,P2,P3,L1,L2)
> #local Normal=vcross(P2-P1,P3-P1);
> #local Plane=plane{Normal 0 translate P1}
> trace(Plane,L1,vnormalize(L2-L1),Normal)
> #end
>
> #macro Split_Angle(PA,PO,PB,Ratio)
> #local VA=PA-PO;
> #local VB=PB-PO;
> #local A=VAngleD(VA,VB);
> #local N=vcross(VA,VB);
> #local P=vaxis_rotate(VA,N,Ratio*A)+PO;
> Ray_Cross_Plane(PO,P,PO+N,PA,PB)
> #end
>
> triangle{ x , 0 , Split_Angle(x,0,y,.1) pigment{color red 1} }
> triangle{ y , 0 , Split_Angle(x,0,y,.1) pigment{color green 1} }
I haven't done much testing, but you may try this macro:
#macro Split_Angle(pA, pO, pB, Ratio)
#local vAB = pB - pA;
#local vA = vnormalize(pA - pO);
#local Angle = degrees(acos(vdot(vA, vnormalize(pB - pO))));
#local vUp = vcross(vA, vAB);
#local vD = vaxis_rotate(vA, vUp, Ratio*Angle);
(pO + vD*vlength(vUp)/vlength(vcross(vD, vAB)))
#end // macro Split_Angle
Tor Olav
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|