Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 88512 invoked from network); 20 May 2010 21:48:25 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 20 May 2010 21:48:25 -0000 Received: (qmail 8663 invoked by uid 500); 20 May 2010 21:48:24 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 8586 invoked by uid 500); 20 May 2010 21:48:24 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 8578 invoked by uid 99); 20 May 2010 21:48:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 May 2010 21:48:24 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [194.206.126.239] (HELO smtp.nordnet.fr) (194.206.126.239) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 May 2010 21:48:15 +0000 Received: from lehrin (73.205.141.79.dynamic.adsl.abo.nordnet.fr [79.141.205.73]) by smtp.nordnet.fr (Postfix) with ESMTP id 90345480CA for ; Thu, 20 May 2010 23:47:53 +0200 (CEST) Received: by lehrin (Postfix, from userid 5001) id AC5F64165; Thu, 20 May 2010 23:47:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on lehrin.spaceroots.local X-Spam-Level: Received: from lehrin.spaceroots.local (lehrin.spaceroots.local [127.0.0.1]) by lehrin (Postfix) with ESMTP id E954A413B for ; Thu, 20 May 2010 23:47:51 +0200 (CEST) Message-ID: <4BF5AE07.4070300@free.fr> Date: Thu, 20 May 2010 23:47:51 +0200 From: Luc Maisonobe User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 MIME-Version: 1.0 To: Commons Users List Subject: Re: [Math] Rotating around global z-axis in processing References: In-Reply-To: X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,FREEMAIL_FROM autolearn=unavailable version=3.3.1 Le 20/05/2010 23:00, Markus Petschnigg a �crit : > Hi! > > We are building an application where we rotate and translate boxes with > different Wiimote metaphors in Processing. > We want to rotate an object around the global processing canvas z-axis, > not around the objects own z-axis. No matter which rotation has been > used before, no matter where the object is in the canvas, this should > just rotate the object around the Processing z-axis. We are using the > Shapes3D libary which is based on apache commons math. The method used > for rotating is called Rot, which is basically the same as in the apache > commons math. > Here is a link to the processing forum, where we also discussed the > issue: http://processing.org/discourse/yabb2/YaBB.pl?num=1272357250/15 > Our entire code is online at: http://code.google.com/p/3d-media-browser/ I would suggest to compute the coordinates of the canvas Z axis in the object frame and to rotate the object around this axis. I assume you have some methods to get or set the orientation fo your object with respect to the canvas. For the sake of the example, I will assume the API is something like : Rotation r1 = myObject.getOrientation(); and myObject.setOrientation(r2); The assumed semantic is that v = r1(u) is such that if u is a vector in object reference frame, v is the vector in the canvas reference frame, i.e. myObject.getOrientation().applyTo(Vector3D.PLUS_K) gives the orientation of the Z axis of the object in the canvas frame. What you want is the opposite, so you have to revert the rotation. You could use something along these lines : Vector3D zAxis = myObject.getOrientation().revert().applyTo(Vector3D.PLUS_K); This vector is the canvas Z axis in the object frame. So if you apply a rotation to the object around this axis, it will rotate around an axis parallel to the canvas Z axis, but containing object origin. If you don't have a getOrientation() method with the assumed semantic, you will have to reconstruct the rotation by yourself. One way to do this is to use the coordinates of two canonical axes of the object as follows: public Rotation getOrientation() { // get the direction of object X axis with respect to canvas frame Vector 3D objectXAxis = ...; // get the direction of object Y axis with respect to canvas frame Vector 3D objectYAxis = ...; return new Rotation(Vector3D.PLUS_I, Vector3D.PLUS_J, objectXAxis, objectYAxis); } Hope this helps, Luc > > Thanks in advance > Markus > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > For additional commands, e-mail: user-help@commons.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org