NTNUJAVA Virtual Physics LaboratoryEnjoy the fun of physics with simulations! Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
September 21, 2020, 05:21:48 pm

Give me a standpoint and I will move the earth. ...Archimedes (287-212BC)

 Pages: [1]   Go Down
 Author Topic: any example xml on angle always made with positive x axis  (Read 13071 times) 0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
lookang
Hero Member

Offline

Posts: 1796

http://weelookang.blogspot.com

 « Embed this message on: August 15, 2007, 12:59:28 am » posted from:Singapore,,Singapore

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
 « Last Edit: August 15, 2007, 01:35:11 am by lookang » Logged
lookang
Hero Member

Offline

Posts: 1796

http://weelookang.blogspot.com

 « Embed this message Reply #1 on: August 15, 2007, 01:14:13 am » posted from:Singapore,,Singapore

alpha =  Math.atan2(vy/vx);

should work but it does not.

strange
 Logged
lookang
Hero Member

Offline

Posts: 1796

http://weelookang.blogspot.com

 « Embed this message Reply #2 on: August 15, 2007, 07:41:21 am » posted from:Singapore,,Singapore

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
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #3 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
 Logged
lookang
Hero Member

Offline

Posts: 1796

http://weelookang.blogspot.com

 « Embed this message Reply #4 on: August 15, 2007, 09:54:39 am » posted from:Singapore,,Singapore

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 !

 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #5 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.
 Logged
lookang
Hero Member

Offline

Posts: 1796

http://weelookang.blogspot.com

 « Embed this message Reply #6 on: August 15, 2007, 12:52:56 pm » posted from:Singapore,,Singapore

prof hwang and prof paco,

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

thanks

wish more people will use EJS to build more diverse applets
 Logged
Fu-Kwun Hwang
Hero Member

Offline

Posts: 3085

 « Embed this message Reply #7 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.
 Logged
 Pages: [1]   Go Up
Give me a standpoint and I will move the earth. ...Archimedes (287-212BC)