# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Capsules orientationPosted: Fri Jul 05, 2013 3:00 pm

Joined: Thu Jun 27, 2013 6:04 pm
Posts: 3
Hi,
I want to apply a force that is pointing forward from the perspective of the capsule body.
So how could I transform a force in capsule's local coordinates to global coordinates. Currently, I am using CapsuleX.
For example, suppose that I want to apply a force of 2 units that pointing forward.
Vector3f localforce= new Vector3f(0,0,2); //Is this local force's direction correct?
Transform t=new Transform();
t=body.getMotionState().getWorldTransform(t);
//transform the force from local coordinates to global coordinates.
Vector3f globalForce=new Vector3f(0,0,0);
globalForce.x=localforce.dot(new Vector3f(t.basis.m00, t.basis.m10, t.basis.m20));
globalForce.y=localforce.dot(new Vector3f(t.basis.m01, t.basis.m11, t.basis.m21));
globalForce.z=localforce.dot(new Vector3f(t.basis.m02, t.basis.m12, t.basis.m22));
body3.setCentralForce(globalForce);

What's wrong with the above code? It seems that sometimes the force is perpendicular to the capsule body instead of pointing forward.
Thank you very much.

Top

 Post subject: Re: Capsules orientationPosted: Fri Jul 05, 2013 5:51 pm

Joined: Tue May 01, 2012 10:42 am
Posts: 97
not sure what is wrong with your code, but maybe it's easier to do something like

Code:
btTransform t;
body.getMotionState().getWorldTransform(t);
t.setOrigin(new btVector3(0,0,0));

btVector3 localForce=new btVector3 (0,1,0);
body.applyCentralForce(t * localForce);

Top

 Post subject: Re: Capsules orientationPosted: Fri Jul 05, 2013 5:54 pm

Joined: Thu Jun 27, 2013 6:04 pm
Posts: 3
STTrife wrote:
not sure what is wrong with your code, but maybe it's easier to do something like

Code:
btTransform t;
body.getMotionState().getWorldTransform(t);
t.setOrigin(new btVector3(0,0,0));

btVector3 localForce=new btVector3 (0,1,0);
body.applyCentralForce(t * localForce);

Thanks! The problem is that I could multiply a transform with vector3f in java.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 3 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Google [Bot] and 11 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ BULLET PHYSICS LIBRARY USERS    General Bullet Physics Support and Feedback    Release Announcements    Applications, Games, Demos or Movies using Bullet PHYSICS AUTHORING TOOLS, SERIALIZATION AND STANDARDS    Physics authoring tools, serialization, standards and related topics RESEARCH AND DEVELOPMENT IN COLLISION DETECTION & PHYSICS. Don't post Bullet support questions here!    Research and development discussion about Collision Detection and Physics Simulation    Links, Papers, Libraries, Demos, Movies, Comparisons       Non-technical forum and license/patent discussion    Career Opportunities