POV-Ray : Newsgroups : povray.advanced-users : another soved problem for solving Server Time
25 Nov 2024 23:45:57 EST (-0500)
  another soved problem for solving (Message 1 to 2 of 2)  
From:
Subject: another soved problem for solving
Date: 14 Dec 2001 09:09:43
Message: <dm0k1uopa5r0am2mhbn0iqckqonnkod89d@4ax.com>
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

From: Tor Olav Kristensen
Subject: Re: another soved problem for solving
Date: 14 Dec 2001 16:27:08
Message: <3C1A6CFA.B8B745A9@hotmail.com>

> 
> 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.