Letting an object slide along a 3D surface in zero-g

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Letting an object slide along a 3D surface in zero-g

Postby Andazeus » Wed Jul 24, 2013 9:13 am

Alright, imagine the following situation:

Image

The blue object is a 3-dimensional, spherical object in zero-g. It is spherical in this example, but it could be pretty much any shape. The red object is attached to the inside of the blue object's surface.

I need to be able to move the red object along that surface freely without the red object ever detaching from it.

Any ideas how to do that in Newton?
Andazeus
 
Posts: 11
Joined: Tue Mar 20, 2012 11:19 am

Re: Letting an object slide along a 3D surface in zero-g

Postby Julio Jerez » Wed Jul 24, 2013 9:28 am

you can connect them with a joint that restrict motion along normal, that would be a plane joint which is very eassy to make.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Letting an object slide along a 3D surface in zero-g

Postby Andazeus » Mon Jul 29, 2013 9:11 am

Is there any documentation on that? So far, I could only find documentation on the other joint types.
Oh, and I'm on Newton2, btw.
Andazeus
 
Posts: 11
Joined: Tue Mar 20, 2012 11:19 am

Re: Letting an object slide along a 3D surface in zero-g

Postby JoeJ » Mon Jul 29, 2013 12:23 pm

Maybe you don't need to code a new joint and the library already contains all that you need?
If not...

Andazeus wrote:Is there any documentation on that?


Go down at 'Userdefines bilateral' at http://newtondynamics.com/wiki/index.php5?title=Joints
There are no changes between 2.x and 3.x about this.

This doc alone won't help much. Take a look at JointLib source code too. It's always the SubmitConstraints method that is most interesting.
Start with CustomBallAndSocket, and see how positions are fused at 3 orthogonal planes, so the meet at a single 3D point.
Note that all Joint Lib code is based on the few Newton functions shown at wiki.
You can either add your own joint to the joint lib using its base class, or do completely on your own.

The User Joint is very flexible. I'm sure you can get what you want after you've got familiar with the basics.
I do not understand what you want exactly from your definition, but it schould by something like:

1. if blue object is polyhedra, find nearest polygon (check velocity on edge / vertex cases to pick proper neighbouring poly)
2. restrict movement to plane of that polygon (You can do easily after you understood ball socket)
3. use plane normal if you wanna constrain orientation too (see UpVector).

EDIT:
Depends on usecase, but wouldn't it be easier to just calculate the gravity force for each object in relation to its enviroment?

EDIT2:
Removed my buggy ellipsoid example.
Last edited by JoeJ on Mon Jul 29, 2013 1:52 pm, edited 2 times in total.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Letting an object slide along a 3D surface in zero-g

Postby Julio Jerez » Mon Jul 29, 2013 12:53 pm

I thonk what he wnat if a joints that aloe movement on the surface of a plane.
whi is very eassy to make

bascially it only restrint the motion along the plane normal, why is the normal of teh intrior of that egg shell and most be fead on each symulation step
Is is one o fte heasies joint to make. just one call to sunmticorntatint.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Letting an object slide along a 3D surface in zero-g

Postby JoeJ » Mon Jul 29, 2013 1:52 pm

I agree that plane constrain is easy, but it is not in joint lib so he needs some help to get started...

Basically to make your own joint you need to setup:
NewtonJoint* joint = NewtonConstraintCreateUserJoint (world, numRows = 1, PlaneSubmitCallback, 0, body0, parentBody = 0);

... and some callback:
void PlaneSubmitCallback(const NewtonJoint* joint, float timestep, int threadIndex)
{
vector planePos (0,0,0);
vector planeNorm (0,1,0);
NewtonUserJointAddLinearRow (joint, bodyCOM, planePos, planeNorm); // example plane constraint
}
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Letting an object slide along a 3D surface in zero-g

Postby Andazeus » Tue Aug 20, 2013 8:40 am

Heya! Just an update since I haven't replied in a while.

I have taken a look at the joints and the basic joint types delivered with Newton are now working for me and I am currently trying to understand custom joints. I am still having a bit of trouble getting a simple plane constraint to run though.

Things are taking a bit longer since I am using OgreNewt and I have to figure out how it wrapped everything (OgreNewt's documentation is unfortunately rather shallow).

I think I understood the basic principle of what you proposed, I am just trying to figure out how to make it work now.
Andazeus
 
Posts: 11
Joined: Tue Mar 20, 2012 11:19 am

Re: Letting an object slide along a 3D surface in zero-g

Postby Julio Jerez » Tue Aug 20, 2013 8:58 am

are you using the new replacement for OgreNewton wrapper?
viewtopic.php?f=2&t=7662

try using that wrapper instead of old Ogrenewt, if you do that I can help you to make the joint using the wraper interface fro joints.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 4 guests