Home   Help Search Login Register  

Author Topic: sine, cosine - guru needed  (Read 784 times)

0 Members and 1 Guest are viewing this topic.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
sine, cosine - guru needed
« on: 19 Dec 2004, 14:42:45 »
i notice sine and cosine can be used in scripts. that being the case i have a request (apologies if this isn't the place for it).

using the smallflare effect, would it be possible to recreate a moving version of the atomic symbol? you know the one i mean? the three particles circling in their respective ellipses.

given my limited ability with the opf syntax i don't even know where to start, but i remember from way way back programming circles in BASIC... can't for the life of me remember how we did it, but i know a loop, a degree variable, sine and cosine were involved...

i'll work on it myself, but if any of you gurus out there can whip something quick up i would be most grateful. i recall the BASIC version was only something like five lines of code. but then that's why it's called basic huh... :)

cheers

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:sine, cosine - guru needed
« Reply #1 on: 19 Dec 2004, 15:18:39 »
Uh huh.....BASIC was good enough in its day, actually it is still used in some circles.

Really it was called BASIC because it means:

Beginners All-Purpose Symbolic Instruction Code.

What exactly do you mean by   'smallflare effect'?



Planck
I know a little about a lot, and a lot about a little.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:sine, cosine - guru needed
« Reply #2 on: 19 Dec 2004, 15:42:52 »
hmmm well the smallflare effect is an extra object added by the great general barron in his editor update. however, after looking up a few BASIC tutorials (ah the memories :) ) - IT WORKS!

place an object, any object, and call it 'circler'. in the init field stick in

Code: [Select]
[] exec "make_circle.sqs"
then copy and paste this into notepad

Code: [Select]
;do a circle

_i=0
_r=3
_xcentre=getpos circler select 0
_ycentre=getpos circler select 1

#loop

circler setpos[(_xcentre+((sin _i)*_r)),(_ycentre+((cos _i)*_r))]

~0.01

_i = _i + 1
?_i>=360:exit

goto "loop"

exit

save as "make_circle.sqs", and preview.

now all i have to do is figure out how to make something circle diagonally...

more coffee required methinks ;)

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:sine, cosine - guru needed
« Reply #3 on: 19 Dec 2004, 15:49:32 »
Quote
?_i>=360:exit
why not make it:
?_i>=360:_i = 0
so it will keep going around

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:sine, cosine - guru needed
« Reply #4 on: 19 Dec 2004, 16:47:12 »
heheheheheh. sigh. mhmm, here i am nesting my loops and all it needs is the loop variable reset.

thankyou sir :)

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:sine, cosine - guru needed
« Reply #5 on: 19 Dec 2004, 22:13:03 »
Heh heh. Trig! Yaay! :D

If it's an ellipse you want, try this:
Code: [Select]
;do an oval

_i=0
_rmax = 8
_rmin = 4
_dr = _rmax - _rmin
_xcentre=getpos circler select 0
_ycentre=getpos circler select 1

#loop

circler setpos[(_xcentre+((sin _i)*(_rmin ))+_dr*(sin(_i))),(_ycentre+((cos _i)*(_rmin))+_dr*(sin(_i)))]

~0.01

_i = _i + 2
?_i>=360:_i = 0

goto "loop"

exit

Or if you want the object to inscribe simple harmonic motion, try this:
Code: [Select]
;do SHM

_i=0
_r=8

_xcentre=getpos circler select 0
_ycentre=getpos circler select 1

_dir = getdir circler

#loop

circler setpos[_xcentre + (sin _dir)*(_r*sin(_i)),_ycentre + (cos _dir)*(_r*sin(_i)),0]

~0.01

_i = _i + 2
?_i>=360:_i = 0

goto "loop"

exit

bored_onion

  • Guest
Re:sine, cosine - guru needed
« Reply #6 on: 21 Dec 2004, 16:11:53 »
someone did a trig tutorial in the ed depot - check it out

Tomasz

  • Guest
Re:sine, cosine - guru needed
« Reply #7 on: 22 Dec 2004, 16:44:58 »
I read in wikipedia that BASIC was first a single word, but because it was so popular, ppl turned into an acronym, like Planck said.

Tomasz