POV-Ray : Newsgroups : povray.advanced-users : rotating in a function Server Time
24 Nov 2024 04:38:02 EST (-0500)
  rotating in a function (Message 1 to 4 of 4)  
From: Leroy Whetstone
Subject: rotating in a function
Date: 28 Feb 2009 23:48:33
Message: <49AA1368.4040206@joplin.com>
I use:
Ang = angle in radians
Fnc=function(x,y,z,Ang){Fna((x-.50)*cos(Ang)+(y-.433)*sin(Ang)+.50,
                     -(x-.50)*sin(Ang)+(y-.433)*cos(Ang),1)+.433};
to rotate a egualaterial triangle in place whose base is at <0,0,0> to 
<1,0,0> and peak is at <.5,.866,0>.
It works when Ang=0.
But doesn't when Ang=radians(120) or Ang=radians(120).

Any Ideas?

I've even try translating another corner of triangle to <0,0,0>
rotating then translating back. Close but there's a noticable gap
from the true triangle.


Post a reply to this message

From: clipka
Subject: Re: rotating in a function
Date: 1 Mar 2009 06:20:01
Message: <web.49aa6f11deb4d92174c3e19a0@news.povray.org>
Leroy Whetstone <lrw### [at] joplincom> wrote:
> I use:
> Ang = angle in radians
> Fnc=function(x,y,z,Ang){Fna((x-.50)*cos(Ang)+(y-.433)*sin(Ang)+.50,
>                      -(x-.50)*sin(Ang)+(y-.433)*cos(Ang),1)+.433};
> to rotate a egualaterial triangle in place whose base is at <0,0,0> to
> <1,0,0> and peak is at <.5,.866,0>.
> It works when Ang=0.
> But doesn't when Ang=radians(120) or Ang=radians(120).
>
> Any Ideas?
>
> I've even try translating another corner of triangle to <0,0,0>
> rotating then translating back. Close but there's a noticable gap
> from the true triangle.

Maybe because you're not perfectly sure what point you should be rotating it
about?

From your formula I gather that you are rotating about <1/2,.866/2,0>. However,
the described equilateral triangle's centroid (i.e. the "center of mass" so to
speak) is at <1/2,.866/3,0>.


Post a reply to this message

From: Leroy Whetstone
Subject: Re: rotating in a function
Date: 1 Mar 2009 12:13:19
Message: <49AAC1AD.8020202@joplin.com>
clipka wrote:
> Maybe because you're not perfectly sure what point you should be rotating it
> about?
> 
> From your formula I gather that you are rotating about <1/2,.866/2,0>. However,
> the described equilateral triangle's centroid (i.e. the "center of mass" so to
> speak) is at <1/2,.866/3,0>.
> 
> 
> 
Your right! Thanks for the help. I was trying to rotate from the center 
of the box contanting the triangle.
I now use the more percise .5*tan(radian(30)) for the y adjust.

Also I had the y componet added to the whole function:
Fnc=function(x,y,z,Ang){Fna((x-.50)*cos(Ang)+(y-.433)*sin(Ang)+.50,
                      -(x-.50)*sin(Ang)+(y-.433)*cos(Ang),1)+.433};
                                                         ^  ^^^^^
                                                         |    This
                                                     Should be here

But now that's taken care of, I get a nice little cracks. (picture attached)

Have fun!


Post a reply to this message


Attachments:
Download 'colors001.gif' (3 KB)

Preview of image 'colors001.gif'
colors001.gif


 

From: Leroy Whetstone
Subject: Re: rotating in a function
Date: 1 Mar 2009 14:17:45
Message: <49AADF21.8040405@joplin.com>
Found the Fix!

#local H30=.5*tan(radians(30));
#local H60=sin(radians(60));
#local 
Fnc=function(x,y,z,Ang){Fna((x-.50)*cos(Ang)+(y*H60-H30)*sin(Ang)+.50, 
 
-(x-.50)*sin(Ang)+(y*H60-H30)*cos(Ang)+H30,0)};

Don't know Why it works but it does!!

Have Fun!


Post a reply to this message

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