APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

Rotation with a variable post and replies

Return to the Rotation with a variable thread
Login to post to this thread

Rotate an indicator
Apostolos Michaloudis
28 Posts

Hello.
I want to create an indicator, like the one the car has to show the current speed.
It is basic a line, which will show the Volts in a simple circuit.

I create a line which i want to rotate 30 degees X Volts.
For example, if V = 2 Volts, i want rotation 30 X 2 = 60 degrees.

I know i can rotate with something like this  ro:30d
but i want something like this:    ro:V*30d    which is not acceptable.
Any suggestions please?


UPDATE
Well, i found another way!
problem is in Transform i cannot insert param with a variable. So i did this:
i created a string variable, lets say  myString.
I inserted this as a parameter in Transform box at the object's properties.
Then, at initialization or evolution or wherever you like write:

myString = "ro:" + 30*V + "d";

so, if variable V has a value 2, then is like the oblject rotates 30*2 = 60 degrees    (ro:60d)
and the object rotates 60 degrees clockwise.

If you have a better way i could use it. Thanks

You can see what i did at   http://www.michaloudis.net/Sims/ERcircuit.jar

Post edited August 1, 2014 at 4:58 PM EST.


OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book