NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Easy Java Simulations (2001- ) => Questions related to EJS => Topic started by: lookang on August 15, 2007, 12:59:28 am



Title: any example xml on angle always made with positive x axis
Post by: lookang on August 15, 2007, 12:59:28 am
i ran into a bug in my codes

my alpha is good for angle 90 to -90 degree.

but when my velocity vector goes to 91 to 180 degree, my alpha is storing the acute angle made with negative x axis.

for example angle made = 150 degree, but my alpha shows -30 degree in the field.

is it because of

1. the conversion from degree to radian ?
2. the Math.sin Math.cos Math.tan formula ? is there another formula for the angle always made with positive x axis ?

attached is my xml :)


Title: Re: any example xml on angle always made with positive x axis
Post by: lookang on August 15, 2007, 01:14:13 am
alpha =  Math.atan2(vy/vx);

should work but it does not.

strange  ???


Title: Re: any example xml on angle always made with positive x axis
Post by: lookang on August 15, 2007, 07:41:21 am
Did it!!

alpha =(Math.atan2(vy,vx))*180/Math.PI;


tricky, noted the comma and it works beautifully.

i am starting to look at the optics examples

a lot of things i want to do can be found !!!

thanks


Title: Re: any example xml on angle always made with positive x axis
Post by: Fu-Kwun Hwang on August 15, 2007, 08:59:59 am
There are some basic information about java programming at http://enjoy.phy.ntnu.edu.tw/mod/resource/view.php?id=8465 (in Chinese).
You will find all the mathematic functions available in java.

Detail information about all the properties in GUI elements can be found at http://enjoy.phy.ntnu.edu.tw/mod/resource/view.php?id=8468
And you can download those html files from http://www.phy.ntnu.edu.tw/demolab/phpBB/osejs/EJS_view_reference.zip


Title: suggest that future version of EJS
Post by: lookang on August 15, 2007, 09:54:39 am
polygon seems a bit harder to implement than analytic curve.

analytic curve is very easy to use for drawing part of a circle

may i suggest that future version of EJS the analytic curve has the same function as polygon " start type and end type"

then EJS can draw a line with an arrow head using  analytic curve.

this is especially useful for drawing angles !
 


Title: Re: any example xml on angle always made with positive x axis
Post by: Fu-Kwun Hwang on August 15, 2007, 10:27:49 am
We try to minimum the parameters need to be changed for all the GUI elements, so user would not think it too complicated.
If you just want to draw angle, It will be easier to use "Line" GUI elements.
Actually, it is a 2D version of polygon.

Your suggestion can be implemented very easily (because it was implemented with polygon element.).
I will ask Paco to add it to the code for the next version.


Title: Re: any example xml on angle always made with positive x axis
Post by: lookang on August 15, 2007, 12:52:56 pm
prof hwang and prof paco,

you guys are the most helpful people i know online !!

thanks  :D

wish more people will use EJS to build more diverse applets


Title: Re: any example xml on angle always made with positive x axis
Post by: Fu-Kwun Hwang on August 15, 2007, 02:37:23 pm
I will be happy if you can keep building more physics simulations with EJS.
And, I hope you can post it here to share with others. ;D