Help me please
Published on May 10, 2007 By thermalsensor In DesktopX
Hi, i have a problem, i'm doing a clock(just for fun), and i need ti make an entire group rotate respect a point, i mean, i have a circule and some other objects in the edge, i want that all objects rotate around the center of the circule.

I hope somebody can help me.
Comments (Page 2)
2 Pages1 2 
on May 22, 2007

Glad to hear you came up with a nice algorithm    One suggestion - you may want to consider calculating certain variables (ex: r*wd or wd*t, but definitely with the Sine and Cosine functions) once and store them in a variable rather than calculating them multiple times using the same values.

Depending on how much time you wanted to invest in making this more efficient, you could actually create an array of precomputed Sine, Cosine values (either statically and copy/paste them into a file or dynamically on each startup) and then reference them later using an index. No matter what language you're using, Sine and Cosine are always slow, but frequently useful depending on what you're looking to do

-Mike
[Stardock Support]

on May 31, 2007
Hi, after a very short vacation, i read the last post.

So now are like 2 am, tomorrow i have school but here is the wheel code(great name don't you think), version 2.0 with arrays and everything jeje, and thnx mike for the idea (this time is the entire code):

Dim t1,r,wd,f
Dim seno(999)
Dim coseno(999)
'Called when the script is executed
Sub Object_OnScriptEnter
r = 100
f=5
wd = .0062832*f
llenarreglo
object.SetTimer 1,10
End Sub

Sub object_ontimer1
t1 = 1+t1
wheel "object",200,200,t1
End Sub

'Called when the script is terminated
Sub Object_OnScriptExit
Object.KillTimer 1
End Sub

'x = center from left
'y = center from top
'wd = rotational veloccity
'f = frecuancy: number of turns each 1 sec
'r = radius
't = incrementant constant
'name = id of the object
'frequency of 1turn/milisecond = 6.2832
'for a angular displacement just add a number to t0
'In the Call of the Function. Example: wheel "object",200,500,t1+100
Function wheel(name,x,y,t)
Dim vp,w
If t >=1000 Then
t = 1 + t - 1000* (Fix(t/1000))
End If

DesktopX.Object(name).Top=y-coseno(t-1)'-r*Cos(wd*t)
DesktopX.Object(name).Left=x+seno(t-1)'+r*Sin(wd*t)
vp = Sqr(((wd*seno(t-1))^2)+((wd*coseno(t-1))^2))'((wd*''r*Sin(wd*t)'')^2)+((wd*''r*Cos(wd*t)'')^2))
w = (vp/r)*(180/3.141592654)
DesktopX.Object(name).Rotation = w*t
End Function

Function llenarreglo
Dim x
For x = 1 To 1000
seno(x-1) = r*Sin(wd*x)
coseno(x-1) = r*Cos(wd*x)
Next
End Function

------------
what you think? cool he. Sorry for some names in spanish but... what ever, Viva México
lol!
on Jun 01, 2007


Nice work on that script!
2 Pages1 2