From: Bruce S. <Bru...@nc...> - 2008-12-07 16:30:05
|
I'm not sure I've understood the issues, but two comments that may be relevant: 1) There is a math routine (imported by Visual) that returns angles between 0 and 2*pi: atan2(y,x). 2) In the documentation for frame there is a routine for converting from a position in a frame to world coordinates. Bruce Sherwood Stef Mientki wrote: > hello, > > playing a few days with vpython, > I'm very satisfied, it's really powerful. > But I've the idea, > I'm missing a few convenience procedures (or at least they are hidden). > > When animating our normal 3D world, > we always have a floor, > as a beginner I've the the xz-plane. > > Now when moving objects with the mouse around in this environment, > I found out that the best thing todo is to project the mouse position on > the floor. > Ok there is a method for, so perfect. > But I also want other vectors to be projected onto the floor, > so I made a small ( 1 line ;-) routine for that. > After moving that routine to a general library, > I discovered that there's also a "proj" routine inside visual. > So apparently there might be some interesting hidden routines ? > > Back to the angle difference, > for my case: mouse position and all objects projected to the floor, > you can unambiguous determine an angle between 0 and 2*pi. > This makes life so much easier. > So why isn't there a procedure for calculating such a difference angle ? > Or am I doing something stupid by projecting everything on the floor ? > Or does nobody uses these kind mouse interactions ? > Or ...? > Anyway here is the small method > > def XZ_Angle ( axis ) : > """projects the vector on the XZ-plane and > calculates the angle with the X-axis [ 0 .. 2*pi ]""" > axis = vector ( axis.x, 0, axis.z ) > a1 = axis.diff_angle ( X_AXIS ) > a2 = axis.diff_angle ( Z_AXIS ) > if a2 < pi/2 : > a1 = 2*pi - a1 > return a1 > > Although trivial, a procedure that translates radians into degrees is > very handy in debugging. > And of course the frame to world translation would be a good candidate > for the convenience library. > > Just some thoughts of a beginner, > > cheers, > Stef Mientki > > > > ------------------------------------------------------------------------------ > SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. > The future of the web can't happen without you. Join us at MIX09 to help > pave the way to the Next Web now. Learn more and register at > http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users |