How to rotate an entire group

Help me please

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.
9,550 views 18 replies
Reply #1 Top
like this? K-Clock
Reply #2 Top
yeah kind of, but in this clock just rotates 2 objects, i want to make something like this but the numbers will be labels, not just one object
Reply #3 Top
aaahhh..... i got nuthin
Reply #5 Top
maybe something here to get you started?
Reply #6 Top
yeah it helps, i think i'm going to do for the hard way!!!

if somebody know how, i'll be gratefull.
Reply #8 Top
Not sure what you have in mind but DX has a built in script to rotate hours,minutes and seconds. It's called analog clock 3
Reply #9 Top
Not sure what you have in mind but DX has a built in script to rotate hours,minutes and seconds. It's called analog clock 3


Yeah, if the objects are specifically time related then Murex's suggestion is by far the easiest way to go.
Reply #11 Top
mmmm in a second thought, after analize the code, is similar to a code that i tried :s
but i need that the object rotate at the same velocity and thats a problem
Reply #12 Top
When you say 'velocity' do you mean specifically related to an actual clock function? eg. hours, minutes, seconds.

If not then what you need to do is adjust the rotation timer. The higher the number will slow it down.

As I played around with this some more, I'm not sure if I made any substantial changes. Anyhoo you can get two new versions. The second one is an example of using multiple objects in the rotation.

Download here --->>>> http://www.sendspace.com/file/5mgia4
Reply #13 Top
When you say 'velocity' do you mean specifically related to an actual clock function? eg. hours, minutes, seconds.

If not then what you need to do is adjust the rotation timer. The higher the number will slow it down.

As I played around with this some more, I'm not sure if I made any substantial changes. Anyhoo you can get two new versions. The second one is an example of using multiple objects in the rotation.

Download here --->>>> http://www.sendspace.com/file/5mgia4

Edit: To adjust the speed also change line 16 under the 'Default Preferences
Code: vbscript
  1. AngularResolution = 60 '180 default
Reply #14 Top
No, i don't mean that.

After mi final exams i'm gonna work in this, i don't have time right now jeje.
Reply #15 Top
Finally!!!!
After finish my final exam of math, i figure out how and here is the function, just are missing some adjustments for displace objects in a same trayectory:

'x = center from left
'y = center from top
'wd = frequency
'r = radius
't = incrementant constant
Function wheel(x,y,wd,r,t)
Dim vp,w
Object.Top=y-r*Cos(wd*t)
Object.Left=x+r*Sin(wd*t)
vp = Sqr(((r*wd*Sin(wd*t))^2)+((r*wd*Cos(wd*t))^2))
w = (vp/r)*(180/3.141592654)
Object.Rotation = (w*t)
End Function
Reply #16 Top

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]

Reply #17 Top
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!
Reply #18 Top


Nice work on that script!