APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

EJsS Error post and replies

Return to the EJsS Error thread
Login to post to this thread

Relative Position of 2d segments
Spencer Wheaton
6 Posts

Dear Paco

I still can't pinpoint the issue with my sim that doesn't run but, in the process of looking for the cause, I found what I think is inconsistent behaviour in the way that the "north-west" and "south-east" relative positions treat the position and size entries of 2D segments.

The X and Y values are not used to specify either endpoint of the segment in these two cases, but instead the X is used for the one endpoint and the Y for the other.  


Replies to Relative Position of 2d segments

Re: Relative Position of 2d segments -
Francisco Esquembre
228 Posts

Hi Spencer,
I think the Segment RelativePosition works fine. However, I have renamed it Offset and restricted it to only 3 possibilities.
  a) the segments starts at (X,Y) and its end point is given by (X+SizeX,Y+SizeY). This is the default and usual math behaviour.
  b) the segment is centered at (X,Y). That is, it starts at (X-SizeX/2,Y-SizeY/2) and ends at  (X+SizeX/2,Y+SizeY/2)
  c) the segment points to (X,Y). That is, it starts at  (X-SizeX,Y-SizeY) and ends at  (X,Y)
This is algo the behaviour for Arrows.

Next release (anyone later than 140921 will have this).
If you used the RelativePosition for Segments before, you may need to clean it, before updating to the new EjsS Release. (Or edit the file 'by hand' to remove this property).


OSP Projects:
Open Source Physics - EJS Modeling
Physlet Physics
Physlet Quantum Physics
STP Book