NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
June 23, 2018, 07:13:53 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Progress is impossible without change; and those who cannot change their minds cannot change anything. ..."George Bernard Shaw(1865-1950, Irish dramatist, essayist and critic, Nobel Prize for Literature 1925)"
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1]   Go Down
  Print  
Author Topic: Represent a vector as horizontal and vertical components applet  (Read 18886 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
lookang
Hero Member
*****
Offline Offline

Posts: 1787


http://weelookang.blogspot.com


WWW
«
Embed this message
on: April 29, 2008, 01:45:51 pm » posted from:Singapore,,Singapore

hihi prof,

how do i make the text strings intelligently display in the applet on the next line.

I previously used a method by spacing but when the display screen auto scale, my spacing is not shown with optimum spacing.

is there a code like
 or next line to make the string automatically go to next line on the applet screen
.

attached is my xml


well i relooked at some of the conversation we had,

i will play with the
You can set those string to the same (x,y) and set different alignment property for those strings (lower right, upper right,lower left, upper left;  4 strings maximum) .
http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=533.msg1802#msg1802

I will be using the method you explained in quotes until i find a better way !!

thanks!!
« Last Edit: May 05, 2008, 09:35:16 am by lookang » Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1787


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #1 on: April 29, 2008, 02:31:28 pm » posted from:Singapore,,Singapore

completed Smiley
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1787


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #2 on: April 29, 2008, 02:37:35 pm » posted from:Singapore,,Singapore

refined completed Cheesy
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #3 on: April 30, 2008, 07:36:59 am » posted from:Taipei,T\'ai-pei,Taiwan

I modified some of the parameter in the EJS and post your beautiful applet -*-

Embed a running copy of this simulation

Embed a running copy link(show simulation in a popuped window)
Full screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
Press the Alt key and the left mouse button to drag the applet off the browser and onto the desktop. This work is licensed under a Creative Commons Attribution 2.5 Taiwan License
  • Please feel free to post your ideas about how to use the simulation for better teaching and learning.
  • Post questions to be asked to help students to think, to explore.
  • Upload worksheets as attached files to share with more users.
Let's work together. We can help more users understand physics conceptually and enjoy the fun of learning physics!
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1787


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #4 on: April 30, 2008, 05:03:41 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

Hi prof

i want to make the applet always show equal size for x and y axes for the reason that circle will look like circle instead of an eclipse.


any tips how to do it??

i try changing the PlottingFrame Size to a variable name "size",

i try making a checkbox to action a function say called showsum()  {actually i instead to equalaxes} Grin

and i added a custom function

but it didn't work.


chance to tip me on the easiest way to mqke a checkbox that when checked will make the PlottingFrame Size equal ?

thanks!
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #5 on: April 30, 2008, 08:30:18 pm »

The x/y axes was determined from properties of DrawingPanel. The default setting was auto-scale in both dimension. You can adjust xmin,xmax,ymin,ymax values to  achieve whatever you want. As long as the x/y dimension of DrawingPanel and ratio of (xmax-xmin)/(ymax-ymin) is the same , you will get equal size for x and y axes.
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1787


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #6 on: May 02, 2008, 09:59:32 am » posted from:Singapore,,Singapore

thanks for your tip and guidance.

managed to do something already.


problem statement on http://forum.java.sun.com/thread.jspa?threadID=5211941&messageID=9855498

trying to write next line.

i tried the method "\n" to go to the next line but it didn't work.

any idea why ?

quote 1: result in /n in the text
s_vxformula = "{A_x}= "+"A*cos("+thetasymbol+"{^o})"+"/n"+" = "+double2String(A,100.)+"*cos("+double2String(alpha,10.)+"{^o})";







thanks!


Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #7 on: May 02, 2008, 10:25:09 am » posted from:Taipei,T\'ai-pei,Taiwan

The method you found: write is display text string in a textarea.
However, in the drawingPanel, what you want to do is DRAW a STRING on the drawing Panel.
To draw, you can draw at any position. For textarea, it was first divided as line, and text can only displayed on those line. So next line make sense. However, there is no next line in the drawing Panel.
That is the reason why it was not working for your case.
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1787


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #8 on: May 02, 2008, 10:36:30 am » posted from:Singapore,,Singapore

ok thanks

seems like have to use the +h method to display the next line ......

it is the update the xml file again

cheers prof  Grin


New title
Represent a vector (A) as horizontal (A_{x}) and vertical A_{y} components
« Last Edit: May 02, 2008, 10:55:27 am by lookang » Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1787


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #9 on: May 05, 2008, 09:32:43 am » posted from:Singapore,,Singapore

hi prof,

i have been trying to make the angle drawn as a dynamic pie for the angle instead of a hollow one, how do i filled the inside with a color ?

i read the reference but still i cant understand the logic of the polygon.

luckily i found

http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=634.0

will study ur codes  Grin


but it seems a bit harder than i thought,

but i did it !!!


under constraints:

what does 2 lines do ? i completely cannot follow

"
 c=cta2-(i-1)*dc; //  c = end of angle segment - (i-1)*a small segment ?
  if(c<-pi)c+=2*pi; // if c less than - Math.PI then c add one until 2*PI ?
"
« Last Edit: May 05, 2008, 10:52:04 am by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #10 on: May 05, 2008, 10:47:48 am »

For 2-D polygon element in the EJS, you need to provide x[n],y[n] arrays to represent the X,Y coordinate for n points.

If the polygon is not closed (you can change the property), then ejs will draw all the points and draw lines between i and i+1 points except the last one.
If the polygon is closed, then it will draw another line connect the last point to the first one. When it is a closed polygon, you can set color to fill the inside of the polygon. 
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1787


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #11 on: May 05, 2008, 10:54:21 am » posted from:SINGAPORE,SINGAPORE,SINGAPORE

i managed to make ur codes work in my applet Smiley

check the post above Smiley

BTW:
what does 2 lines do ? i completely cannot follow

"
 c=cta2-(i-1)*dc; //  c = end of angle segment - (i-1)*a small segment ?
  if(c<-pi)c+=2*pi; // if c less than - Math.PI then c add one until 2*PI ?
"
« Last Edit: May 05, 2008, 01:37:17 pm by lookang » Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1787


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #12 on: May 05, 2008, 01:34:31 pm » posted from:Singapore,,Singapore

final version, i hope Smiley

Represent a vector as two perpendicular components ( x and y direction )
« Last Edit: May 05, 2008, 02:05:23 pm by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #13 on: May 05, 2008, 06:57:30 pm »

i managed to make ur codes work in my applet Smiley

check the post above Smiley

BTW:
what does 2 lines do ? i completely cannot follow

"
 c=cta2-(i-1)*dc; //  c = end of angle segment - (i-1)*a small segment ?
  if(c<-pi)c+=2*pi; // if c less than - Math.PI then c add one until 2*PI ?
"

The purpose of the above code is to make sure angle c would not be less than -pi;
If it is less than -pi, add the angle with 2*pi.
I think the purpose is to have correct calculated components.
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1787


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #14 on: May 05, 2008, 07:13:12 pm » posted from:Mountain View,California,United States

oic.... cool...never thought of that....thanks!

the applet now here http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=681.0
« Last Edit: March 05, 2009, 03:13:27 pm by lookang » Logged
Pages: [1]   Go Up
  Print  
Progress is impossible without change; and those who cannot change their minds cannot change anything. ..."George Bernard Shaw(1865-1950, Irish dramatist, essayist and critic, Nobel Prize for Literature 1925)"
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Ejs open source Represent vector horizontal and vertical components java applet
Collaborative Community of EJS
lookang 5 15189 Last post December 17, 2011, 08:28:02 pm
by Gaven
Circular motion: acceleration always perpendicular to velocity
Dynamics
Fu-Kwun Hwang 7 65219 Last post October 21, 2015, 01:32:10 pm
by freddygon
Ejs Open source java applet Resolving a Vector in 2 perpendicular directions
Collaborative Community of EJS
lookang 1 8837 Last post March 02, 2009, 06:00:50 am
by lookang
Circular motion: acceleration always perpendicular to velocity
dynamics
ahmedelshfie 0 4908 Last post June 08, 2010, 06:43:50 pm
by ahmedelshfie
vector sum/substract
misc
Fu-Kwun Hwang 0 3589 Last post September 28, 2014, 08:26:12 am
by Fu-Kwun Hwang
Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.068 seconds with 22 queries.since 2011/06/15