Cylinder and capsule, 2 radii?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Cylinder and capsule, 2 radii?

Postby hpesoj » Fri Aug 07, 2009 12:10 pm

The collision shape creation functions only allow for a single radius value to be specified, but the collision shape info structures seem to indicate that its possible to have cylinders and capsules with two distinct radii. Is this a mistake, or is this functionality simply not exposed yet? NB. this is not the case for cones and chamfer cylinders.

Code: Select all
      struct NewtonCylinderParam
      {
         dFloat m_r0;
         dFloat m_r1;
         dFloat m_height;
      };

      struct NewtonCapsuleParam
      {
         dFloat m_r0;
         dFloat m_r1;
         dFloat m_height;
      };
hpesoj
 
Posts: 90
Joined: Sun Jan 09, 2005 4:36 pm
Location: Cambridge/Bristol, UK

Re: Cylinder and capsule, 2 radii?

Postby Julio Jerez » Fri Aug 07, 2009 12:39 pm

If yo ucheck teh sphere, they also have tree radius.
At one time I was workin out the math for cilinders with two radius but it is too expensive because it involve projection matrix in each iteration, Plus is hard to get the contact normals
For spheres it is simple since the Transform is not a projection matrix.
Maybe one day I will do it, but that is not a feature that is really on demand.

Basically now the two variables are set to the same radius
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Cylinder and capsule, 2 radii?

Postby hpesoj » Fri Aug 07, 2009 4:40 pm

Thanks.

If yo ucheck teh sphere, they also have tree radius.


But you can specify three radii for the sphere, so technically it's not a sphere if you have different sized radii, but the info structure is correct, no?
hpesoj
 
Posts: 90
Joined: Sun Jan 09, 2005 4:36 pm
Location: Cambridge/Bristol, UK

Re: Cylinder and capsule, 2 radii?

Postby Julio Jerez » Fri Aug 07, 2009 5:12 pm

hpesoj wrote:But you can specify three radii for the sphere, so technically it's not a sphere if you have different sized radii, but the info structure is correct, no?

it is a general ellipsoid.

There is a expresion for General Conic that can do Cones, Cylindes, and capsule but it make teh code slower than it need to be, tehrefore I end up doing using eh special case funtions.
Buit in General all three shape can be replaced with one Gerneral conic shape.

It is a Pedante exersize in Algebra tha leads to not real Gain. Plsu it will mak eteh interface more confusin fo people.
Imagine specifying a sphere or a cone or a Parabolid shape with 9 coeficient, instead oft parameters that make sense to everyone.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Cylinder and capsule, 2 radii?

Postby kallaspriit » Wed Aug 12, 2009 9:24 am

Can't you make cylinders and ellipsoids of variable radius's using collision modifier scale?
kallaspriit
 
Posts: 216
Joined: Sun Aug 14, 2005 6:31 pm

Re: Cylinder and capsule, 2 radii?

Postby Julio Jerez » Wed Aug 12, 2009 10:02 am

Unfortunately no, the reason is that convex property is invariant under affine transformation but there are no invariant under perspective reformation.
Invariant just means the propriety is preserved before and after the transformation.

The modifier is an affine Matrix which can change the shape of a convex shape but can no change the convexity. Affine matrices can have shear and non uniform scale.

say you have matrix M and homogeneous points P0(x, y, z, 1)
after the transformation is you get another homogenous point p1 ( sx * x, sy * y, sz * z, 1)
you can have the real point by dividing by the four parameter, by as you can see parameter w does not change:
the shape made by all points transformed by M will preserve convexity if the untransformed shape was convex.

if M was a perspective matrix, then point P1 would be P1 (sx * x, sy * y, sz * z, sw)
and the final point P1’ (sx * x / ws, sy * y / ws, sz * z / ws, 1)

The shape made by all point P1’ may or may not be convex. And that made it a very intractable problem.
The good news if the perspective transform may produce convex transform on some region of the 3d space, so with care it is possible but it is very time consuming.

To give you an idea one of the simplest perspective transform in the Perceptive matrix you use in OpenGL and D3D,
you know the transform shape resemble the untransformed shape, only if the shape is inside the view frustum of View, outside the frustum it becomes is undefined.
The generalization of Perspective matrices are a little harder because the can be for any three axis, and the region for which the transformed preserve convexity is much, much harder to determine.

In any case I may one day try if I feel like it, but there are still lots of feature that are more useful and more important than having cylinder with variable radius.
You are the first person interested in that kind of shape; do you need then for anything?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
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 45 guests