POV-Ray : Newsgroups : povray.newusers : Rotating triangle around middle point Server Time
1 Nov 2024 00:25:25 EDT (-0400)
  Rotating triangle around middle point (Message 1 to 6 of 6)  
From: RayZ
Subject: Rotating triangle around middle point
Date: 11 Sep 2011 17:55:00
Message: <web.4e6d2d8138a9622beee66afe0@news.povray.org>
Hi, once again I've stumbled upon a problem. I have two triangles which are not
parallel to any axis. I want it so that one of the triangles rotates around in
place until it is pointing the opposite way of the other one, forming a
hexagram.
If I use scale -1, the triangle does go to it's opposite, but as soon as I put
in a clock the "rotating" triangle shrinks and continues to grow in size
pointing the opposite way all the time.

example code for rotating triangle:

#declare a = <1,1,0>;
#declare b = <1,0,-1>;
#declare c = <0,1,-1>;

//moving
triangle{ a, b, c
pigment{rgbf <1,0,0,.5>}
translate -a/3 translate -b/3 translate -c/3
scale -1 * clock
translate a/3 translate b/3 translate c/3
}

//stationary
triangle{ a, b, c
pigment{rgbf <1,1,0,.5>}
}

any help would be appreciated, thanks.


Post a reply to this message

From: Alain
Subject: Re: Rotating triangle around middle point
Date: 11 Sep 2011 18:23:06
Message: <4e6d34ca@news.povray.org>

> Hi, once again I've stumbled upon a problem. I have two triangles which are not
> parallel to any axis. I want it so that one of the triangles rotates around in
> place until it is pointing the opposite way of the other one, forming a
> hexagram.
> If I use scale -1, the triangle does go to it's opposite, but as soon as I put
> in a clock the "rotating" triangle shrinks and continues to grow in size
> pointing the opposite way all the time.
>
> example code for rotating triangle:
>
> #declare a =<1,1,0>;
> #declare b =<1,0,-1>;
> #declare c =<0,1,-1>;
>
> //moving
> triangle{ a, b, c
> pigment{rgbf<1,0,0,.5>}
> translate -a/3 translate -b/3 translate -c/3
> scale -1 * clock
> translate a/3 translate b/3 translate c/3
> }
>
> //stationary
> triangle{ a, b, c
> pigment{rgbf<1,1,0,.5>}
> }
>
> any help would be appreciated, thanks.
>
>
>
>

You correctly move your triangle around the origin, transform it, then 
translate it back in it's desired location. Good.

Your "scale -1*clock" (same as scale<-1,-1,-1>*clock) is an isotrope 
scaling. What you seems to want is a rotation of your triangle going 
from 0 to 180 degree over the course of your animation.
It may also be that you want your triangle to shrink down to almost 
nothing, then grow back as a reversed image of it's original shape.

First case, use rotate [axis]*clock*180

Second case, you need to adjust your scaling range. Sample:
scale 1-clock*2
This gives an effective range going from <1,1,1> to <-1,-1,-1>.

This will make your object start at it's full size, shring down, then 
expand back to it's original size but with it's dimentions inverted.
In this case, you MUST ensure that clock NEVER reatch exactly 0.5. This 
will cause a scaling by zero whitch is undefined and will default to 
scale 1 with a warning been isued.



Alain


Post a reply to this message

From: Stephen
Subject: Re: Rotating triangle around middle point
Date: 11 Sep 2011 19:18:46
Message: <4e6d41d6$1@news.povray.org>
On 11/09/2011 10:52 PM, RayZ wrote:
> Hi, once again I've stumbled upon a problem. I have two triangles which are not
> parallel to any axis. I want it so that one of the triangles rotates around in
> place until it is pointing the opposite way of the other one, forming a
> hexagram.
> If I use scale -1, the triangle does go to it's opposite, but as soon as I put
> in a clock the "rotating" triangle shrinks and continues to grow in size
> pointing the opposite way all the time.

I read your question differently from Alain. It all depends how you want 
your triangle to rotate. If you want it to rotate around its centre of 
gravity. then you construct it so that the centre of gravity (or the 
centre of rotation) is at the origin. Rotate it, with the clock 
variable, then move it to the required position. You may need to rotate 
it using the three axis and the sin and cos functions.

-- 
Regards
     Stephen


Post a reply to this message

From: RayZ
Subject: Re: Rotating triangle around middle point
Date: 11 Sep 2011 20:55:00
Message: <web.4e6d5808dbede6f8eee66afe0@news.povray.org>
Alain <aze### [at] qwertyorg> wrote:
>
> You correctly move your triangle around the origin, transform it, then
> translate it back in it's desired location. Good.
>
> Your "scale -1*clock" (same as scale<-1,-1,-1>*clock) is an isotope
> scaling. What you seems to want is a rotation of your triangle going
> from 0 to 180 degree over the course of your animation.
> It may also be that you want your triangle to shrink down to almost
> nothing, then grow back as a reversed image of it's original shape.
>
> First case, use rotate [axis]*clock*180
>
> Second case, you need to adjust your scaling range. Sample:
> scale 1-clock*2
> This gives an effective range going from <1,1,1> to <-1,-1,-1>.
>
> This will make your object start at it's full size, shrink down, then
> expand back to it's original size but with it's dimensions inverted.
> In this case, you MUST ensure that clock NEVER reach exactly 0.5. This
> will cause a scaling by zero which is undefined and will default to
> scale 1 with a warning been issued.
>
>
>
> Alain

Ok, I'll use
rotate [axis]*clock*180
, but I don't know how to find the axis.
from the three points I made a 4th one which was the center of the 3, which the
triangle is supposed to rotate on

#declare a = <1,1,0>;
#declare b = <1,0,-1>;
#declare c = <0,1,-1>;
#declare d = <2/3,2/3,-2/3>;

but I don't know how to rotate it around and keep the 2 triangles coplanar.

OK I'll stop "lying". I actually want to make an animation where an icosahedron
has triangles which grow to a specified size, and rotate (on axis) 180 degrees
during the growth.
here is an example

#declare B  = <0,1,-1.618>;
#declare E  = <1,1.618,0>;
#declare J  = <1.618,0,-1>;

union{
triangle{ B, E, J pigment{ rgbf<1,0,0,0>}    //colour and points
translate -B/3 translate -E/3 translate -J/3 //translate to origin
scale (14 + 6 * sqrt(5)) / 4 * clock         //specified resize
rotate <0,0,0>                               //the part where it rotates 180 on
the axis, need help on this
translate B/3 translate E/3 translate J/3    //translate back
finish{ambient 0.5}                          //brighter :P
}

so if you can please clarify the axis part, thanks.


Post a reply to this message

From: Solar Mike
Subject: Re: Rotating triangle around middle point
Date: 11 Sep 2011 23:55:00
Message: <web.4e6d81a5dbede6f8776f1f120@news.povray.org>
>
> Ok, I'll use
> rotate [axis]*clock*180
> , but I don't know how to find the axis.
> from the three points I made a 4th one which was the center of the 3, which the
> triangle is supposed to rotate on
>
> #declare a = <1,1,0>;
> #declare b = <1,0,-1>;
> #declare c = <0,1,-1>;
> #declare d = <2/3,2/3,-2/3>;
>
> but I don't know how to rotate it around and keep the 2 triangles coplanar.
>
> OK I'll stop "lying". I actually want to make an animation where an icosahedron
> has triangles which grow to a specified size, and rotate (on axis) 180 degrees
> during the growth.
> here is an example
>
> #declare B  = <0,1,-1.618>;
> #declare E  = <1,1.618,0>;
> #declare J  = <1.618,0,-1>;
>
> union{
> triangle{ B, E, J pigment{ rgbf<1,0,0,0>}    //colour and points
> translate -B/3 translate -E/3 translate -J/3 //translate to origin
> scale (14 + 6 * sqrt(5)) / 4 * clock         //specified resize
> rotate <0,0,0>                               //the part where it rotates 180 on
> the axis, need help on this
> translate B/3 translate E/3 translate J/3    //translate back
> finish{ambient 0.5}                          //brighter :P
> }
>
> so if you can please clarify the axis part, thanks.

I think you are just looking for the normal of the triangle right?  If so, you
can just use a cross product..
  Axis_Rotate_Trans(vcross(E-B, J-B), 180)

There may be a more elegant way but I think that will work.


Post a reply to this message

From: Alain
Subject: Re: Rotating triangle around middle point
Date: 12 Sep 2011 17:43:51
Message: <4e6e7d17@news.povray.org>

> Alain<aze### [at] qwertyorg>  wrote:
>>
>> You correctly move your triangle around the origin, transform it, then
>> translate it back in it's desired location. Good.
>>
>> Your "scale -1*clock" (same as scale<-1,-1,-1>*clock) is an isotope
>> scaling. What you seems to want is a rotation of your triangle going
>> from 0 to 180 degree over the course of your animation.
>> It may also be that you want your triangle to shrink down to almost
>> nothing, then grow back as a reversed image of it's original shape.
>>
>> First case, use rotate [axis]*clock*180
>>
>> Second case, you need to adjust your scaling range. Sample:
>> scale 1-clock*2
>> This gives an effective range going from<1,1,1>  to<-1,-1,-1>.
>>
>> This will make your object start at it's full size, shrink down, then
>> expand back to it's original size but with it's dimensions inverted.
>> In this case, you MUST ensure that clock NEVER reach exactly 0.5. This
>> will cause a scaling by zero which is undefined and will default to
>> scale 1 with a warning been issued.
>>
>>
>>
>> Alain
>
> Ok, I'll use
> rotate [axis]*clock*180
> , but I don't know how to find the axis.
> from the three points I made a 4th one which was the center of the 3, which the
> triangle is supposed to rotate on
>
> #declare a =<1,1,0>;
> #declare b =<1,0,-1>;
> #declare c =<0,1,-1>;
> #declare d =<2/3,2/3,-2/3>;
>
> but I don't know how to rotate it around and keep the 2 triangles coplanar.
>
> OK I'll stop "lying". I actually want to make an animation where an icosahedron
> has triangles which grow to a specified size, and rotate (on axis) 180 degrees
> during the growth.
> here is an example
>
> #declare B  =<0,1,-1.618>;
> #declare E  =<1,1.618,0>;
> #declare J  =<1.618,0,-1>;
>
> union{
> triangle{ B, E, J pigment{ rgbf<1,0,0,0>}    //colour and points
> translate -B/3 translate -E/3 translate -J/3 //translate to origin
> scale (14 + 6 * sqrt(5)) / 4 * clock         //specified resize
> rotate<0,0,0>                                //the part where it rotates 180 on
> the axis, need help on this
> translate B/3 translate E/3 translate J/3    //translate back
> finish{ambient 0.5}                          //brighter :P
> }
>
> so if you can please clarify the axis part, thanks.
>
>
>
>
>
>
>

For that, it may be beter to originaly create all your triangles along 

rotation around a single axis (Z, Y or X), then rotate and translate 
them to the desired final orientations and locations.

It may look more complicated, but, in the end can be much simpler to 
implement.

OR

You can go along with the proposition of Solar Mike and use:
Axis_Rotate_Trans(vcross(E-B, J-B), 180*clock)

You need to add:
#include "transforms.inc"
early in your scene to use that.


Other notes:
I don't recomend the use of finish{ambient 0.5} to make something 
brighter. This tend to flatten your shading and make you loose the 3D 
quality.
Increase the light's intensity instead, it's intensity is not limited to 
rgb<1,1,1>.

You can use another light, possibly coloured, to make shadowed parts 
brighter.

If you don't use transparency, use rgb<1,0,0> instead of rgbf<1,0,0,0>.
Here, also, the colour range is not limited to 0~1 range. Be carefull 
that you don't over saturate your colours and cause some clipping.

If your union only contains a single component, use object instead.

If all the components of an union share the same texture, apply that 
texture to the union as a whole and only give a texture to a component 
that have a different texture.



Alain


Post a reply to this message

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