NTNUJAVA Virtual Physics LaboratoryEnjoy the fun of physics with simulations! Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
September 25, 2020, 04:03:54 am
 Welcome, Guest. Please login or register.Did you miss your activation email? 1 Hour 1 Day 1 Week 1 Month Forever Login with username, password and session length

 Home Help Search Login Register
Never too late. Never too early. ...Wisdom

 Pages: [1]   Go Down
 Author Topic: any example xml on angle always made with positive x axis  (Read 13077 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
Administrator
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
And you can download those html files from http://www.phy.ntnu.edu.tw/demolab/phpBB/osejs/EJS_view_reference.zip
 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
Administrator
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
Administrator
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
Never too late. Never too early. ...Wisdom
Jump to:

 Related Topics Subject Started by Replies Views Last post how to make x and y axis automatically on the drawing panel Questions related to EJS lookang 4 14591 August 10, 2007, 02:35:48 pm by lookang how to draw a fraction of a circle for angle showing in plotting panel Questions related to EJS lookang 7 18444 August 15, 2007, 08:55:15 am by Fu-Kwun Hwang what is the best way to share java applets made by EJS ? Questions related to EJS lookang 11 15011 April 05, 2015, 02:08:36 am by Femida How to make an applet that is controlled by F (length) and angle (cta) Questions related to EJS lookang 4 9544 March 02, 2009, 10:22:45 pm by Fu-Kwun Hwang how to transform about an axis a rotation using Matrix3DTransformation ? Questions related to EJS lookang 2 17229 August 24, 2012, 03:16:04 pm by lookang
Page created in 0.06 seconds with 23 queries.since 2011/06/15