POV-Ray : Newsgroups : povray.general : cos & sin functions Server Time
5 Nov 2024 12:37:38 EST (-0500)
  cos & sin functions (Message 1 to 7 of 7)  
From: Tjeiken
Subject: cos & sin functions
Date: 19 Feb 2005 15:55:03
Message: <web.4217a68c1eb30463d977fb9c0@news.povray.org>
i'm working on a trebuchet, that i should have animated. The problem is,
that i gotta have a piece rotating around a centerpoint in a circle. I'm
going to use cos and sin functions to get the x and y coordinates like
this:
cos(A)*r=x
sin(A)*r=y

A=angle r=radius
The problem is, that when i use it, either the POV-Ray, or my calculator are
calculating wrong - most likely POV-Ray. my .pov code looks like this:
----------------------------------
#include "woods.inc"
declare beam = box{<0,0,0><1,1,1>
texture{T_Wood20}
}
#declare ANGLE = 1; /*change this to 1,2,3 etc.*/
object{beam scale<1.9,35.56,1.27> translate<0,43,2.54> translate
x*cos(ANGLE)*-22.86 translate y*sin(ANGLE)*-22.86}
--------------------------------------------
For me, it just looks like the beam is jumping around, rather than following
a circular pattern, which it should do.
Hope you can help me.
-Tjeiken


Post a reply to this message

From: B  Gimeno
Subject: Re: cos & sin functions
Date: 19 Feb 2005 16:03:42
Message: <4217a9ae$1@news.povray.org>
Hi,
take in count that pov rotates objects en degrees, but count sin and cos
functions in radians, then
instead
object {XX rotate x*cos(30),
use a conversion inside de cos function
object {XX rotate x*cos(radians(30))}
--
B Gimeno
estoeslarealidad
http://usuarios.lycos.es/game2413
----------------------------------------------------------------------------
light_source {0,1}#local C=cylinder{x*-2,x*2,.9}difference{box{-1,1}object{C
pigment {red 1}}object{C rotate y*90 pigment{green 1}}object{C rotate z*90
pigment{blue 1}} pigment{rgb 3}rotate 45 translate z*4}


news:web.4217a68c1eb30463d977fb9c0@news.povray.org...
> i'm working on a trebuchet, that i should have animated. The problem is,
> that i gotta have a piece rotating around a centerpoint in a circle. I'm
> going to use cos and sin functions to get the x and y coordinates like
> this:
> cos(A)*r=x
> sin(A)*r=y
>
> A=angle r=radius
> The problem is, that when i use it, either the POV-Ray, or my calculator
are
> calculating wrong - most likely POV-Ray. my .pov code looks like this:
> ----------------------------------
> #include "woods.inc"
> declare beam = box{<0,0,0><1,1,1>
> texture{T_Wood20}
> }
> #declare ANGLE = 1; /*change this to 1,2,3 etc.*/
> object{beam scale<1.9,35.56,1.27> translate<0,43,2.54> translate
> x*cos(ANGLE)*-22.86 translate y*sin(ANGLE)*-22.86}
> --------------------------------------------
> For me, it just looks like the beam is jumping around, rather than
following
> a circular pattern, which it should do.
> Hope you can help me.
> -Tjeiken
>
>


Post a reply to this message

From: Chris B
Subject: Re: cos & sin functions
Date: 19 Feb 2005 16:10:35
Message: <4217ab4b@news.povray.org>
"Tjeiken" <nomail@nomail> wrote in message
news:web.4217a68c1eb30463d977fb9c0@news.povray.org...
> ... snip .... I'm going to use cos and sin functions to get the x and y
> coordinates ... snip ...
> The problem is, that when i use it, either the POV-Ray, or my calculator
> are calculating wrong ... snip ...
> Hope you can help me.
> -Tjeiken
>

It's not just that sin() and cos() are in Radians is it?
If you're thinking in Degrees you need sind() and cosd().

Regards,
Chris B.


Post a reply to this message

From: Bob Hughes
Subject: Re: cos & sin functions
Date: 19 Feb 2005 16:25:33
Message: <4217aecd$1@news.povray.org>
"B. Gimeno" <nos### [at] yacom> wrote in message 
news:4217a9ae$1@news.povray.org...
> take in count that pov rotates objects en degrees, but count sin and cos
> functions in radians, then
> instead
> object {XX rotate x*cos(30),
> use a conversion inside de cos function
> object {XX rotate x*cos(radians(30))}
> --
> B Gimeno

Yes, the following rotates the wood beam in a complete circle:

camera {location -100*z up y right image_width/image_height*x look_at 50*y}

light_source {<100,100,-100>,1}

#include "colors.inc"
#include "woods.inc"

declare beam = box {
 <0,0,0><1,1,1>
texture {T_Wood20}
}

#declare ANGLE = radians(clock*360);

object {
 beam
 scale <1.9,35.56,1.27>
 translate <cos(ANGLE)*-22.86,43+sin(ANGLE)*-22.86,2.54>
}


Post a reply to this message

From: Warp
Subject: Re: cos & sin functions
Date: 19 Feb 2005 17:26:07
Message: <4217bcff@news.povray.org>
Chris B <c_b### [at] btconnectcom> wrote:
> If you're thinking in Degrees you need sind() and cosd().

  Need? Not really. He *can* use them, but that's not the same as need. :)
  He can just use sin(radians(angle)) and cos(radians(angle)).

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: kurtz le pirate
Subject: Re: cos & sin functions
Date: 20 Feb 2005 01:39:44
Message: <kurtzlepirate-9E51FD.07394420022005@news.povray.org>
In article <web.4217a68c1eb30463d977fb9c0@news.povray.org>,
 "Tjeiken" <nomail@nomail> wrote:

>>i'm working on a trebuchet, that i should have animated. The problem is,
>>that i gotta have a piece rotating around a centerpoint in a circle. I'm
>>going to use cos and sin functions to get the x and y coordinates like
>>this:
>>cos(A)*r=x
>>sin(A)*r=y
>>
>>A=angle r=radius
>>The problem is, that when i use it, either the POV-Ray, or my calculator are
>>calculating wrong - most likely POV-Ray. my .pov code looks like this:
>>----------------------------------
>>#include "woods.inc"
>>declare beam = box{<0,0,0><1,1,1>
>>texture{T_Wood20}
>>}
>>#declare ANGLE = 1; /*change this to 1,2,3 etc.*/
>>object{beam scale<1.9,35.56,1.27> translate<0,43,2.54> translate
>>x*cos(ANGLE)*-22.86 translate y*sin(ANGLE)*-22.86}
>>--------------------------------------------
>>For me, it just looks like the beam is jumping around, rather than following
>>a circular pattern, which it should do.
>>Hope you can help me.
>>-Tjeiken


yes use sind() and cosd() like this :


#macro sind(deg_angle) sin(radians(deg_angle)) #end
#macro cosd(deg_angle) cos(radians(deg_angle)) #end

#declare a = 30; // 30 degrees
#debug concat("\n sin(",str(a,0,0),") = ",str(sind(a),14,12))
#debug concat("\n cos(",str(a,0,0),") = ",str(cosd(a),14,12))
#debug "\n\n"


hope that help


Post a reply to this message

From: Tjeiken
Subject: Re: cos & sin functions
Date: 21 Feb 2005 10:35:00
Message: <web.4219feb1518b8c2dd977fb9c0@news.povray.org>
Thx for all the help.. it works as it is supposed to now :)


Post a reply to this message

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