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 February 14, 2011, 04:51:14 pm



Title: how to create a polygon angle in 3D view?
Post by: lookang on February 14, 2011, 04:51:14 pm
how to create a polygon angle in 3D view?

currently i am able to make a polygon in 2D Ejs view.

but when i try to use the same idea to draw a polygon in 3D view of Ejs, it didn't seem to draw it.

may i request for a sample xml that draw a polygon in 3D view of Ejs?

want i am trying to do is to draw a polygon from vector B (magnetic field direction) to vector A (area) in 3D view.

i also attached my xml in case i am not clear


Title: Re: how to create a polygon angle in 3D view?
Post by: Fu-Kwun Hwang on February 14, 2011, 05:37:32 pm
For polygon3D:
 you can enter either Data property: which is a [n][3] two dimension array.
Or provide Xdata,Ydata and Zdata.

You should not type in nangle as Data property (remove it, if you want to specify px,py,pz)

Position and Size is used to move the whole polygon (displacement).
Do not need to enter anything inside that group unless you know what you were doing.
(remove all those values)

There are too many GUI elements, I do not know how to fix your ejs source.
Please try it again by yourself!


Title: Re: how to create a polygon angle in 3D view?
Post by: lookang on February 14, 2011, 08:37:06 pm
yes i do it :)
dcangle = (ctadegree0360+90)*pi/180/(nangle-2);
//dcangle = cta/(n-2);
// px[0] and px[0] define the centre of polygon
px[0]=x0; // for drawing angle polygon
py[0]=y0; //
// if statement to draw polygon angle
for(int i=1;i<nangle;i++){
//  c=Math.atan2(y,x)-(i-1)*dcangle;  // modify to work drawing from black line
//  c=(Math.atan2(y,x))-(i-1)*dcangle;
c = (ctadegree0360+90)*pi/180-(i-1)*dcangle;

// if(c>pi)c-=2*pi; // to overcome pi to -pi problem
 // if(c<-pi)c+=2*pi;
 // else if (c>pi) c-=2*pi;
px=x0+d*Math.cos(c); //
py=y0+d*Math.sin(c); //
}

i am getting better at ejs :)