POV-Ray : Newsgroups : povray.advanced-users : Rotation between 2 angles : Rotation between 2 angles Server Time
8 Jun 2024 02:12:26 EDT (-0400)
  Rotation between 2 angles  
From: Fractracer
Date: 6 Jan 2014 08:50:01
Message: <web.52cab4641b5a436f673d78420@news.povray.org>
I write a macro use for create path for animations, the macro return an array of
<x,y,z> values. The problem I have is: how do I make to have a good rotation
between two angles? Actually the object look alwways in the same direction.
Here is the macro:

#macro calc_path(nbr_elem, AngleXY, AngleZ, seed1)
 #local S0 = 0;    //start
 #local S1 = nbr_elem;  //end
 #local ALEA = seed(seed1);

 #local Values = array[S1]
 #local OX = 0;  //Old X;
 #local OY = 0;  //Old Y;
 #local OZ = 0;  //Old Z;
 #local OA = 0;  //Old Angle;
 #local OAz = 0;  //Old Angle z;

 #local X = 0;
 #local Y = 0;
 #local Z = 0;
 #local AC = AngleXY;
 #local AD = AC/2;

 #while (S0<S1)
  #local NA = (AD - floor(rand(ALEA)*AC))+OA;
  #local OA = mod(NA,360);
  #local C = cosd(NA);
  #local S = sind(NA);

  #local X = OX+C;
  #local Y = OY+S;

  #local NAz = floor(rand(ALEA)*AngleZ)+OAz;
  #local OAz = mod(NAz,360);
  #local Sz = sind(NAz);
  #local Z = OZ+Sz;
  #local Values[S0]= <X,Y,Z>;
  #local OX = X;
  #local OY = Y;
  #local OZ = Z;
  #local S0 = S0+1;
 #end
 Values
#end

And the initialisation and use of the macro.

#local ELM = 25;
#local V = array[ELM];

#local V = calc_path(ELM, 100, 70, 1234);

#local Shape = union {
 box {<-0.25,0.0,-0.1>  <0.5,0.25,0.1> pigment {color rgb <0.1,0.1,0.1>}}
 box {< 0.25,0.1,-0.3>  <0.5,0.15,0.3> pigment {color rgb <0.5,0.5,0.5>}}
}

union {
 #local start = 0;
 #while (start<ELM)
     object {
     Shape
 translate V[start]
 }
 #local start = start+1;
 #end
}

Can somebody help me?


Post a reply to this message

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