ConstantAngularSpeedCurve ?

Discuss any questions about BEPUphysics or problems encountered.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: ConstantAngularSpeedCurve ?

Post by Norbo »

So the better solution, is to have a normal driving ?
Yes.
Bepuphysics give helper for quaternion comparaison ?
Sort of. These methods are sometimes useful:
Toolbox.GetAngleFromQuaternion
Toolbox.GetAxisAngleFromQuaternion
Toolbox.GetQuaternionBetweenNormalizedVectors

Another useful operation for comparison is computing the intermediate rotation between two orientation quaternions, which you can get with a conjugate and multiply.

Also, since you're primarily concerned with the forward direction versus a desired direction, you should be able to avoid quaternions in favor of simple dot products or projections.
kavatortank
Posts: 91
Joined: Tue May 14, 2013 12:17 pm

Re: ConstantAngularSpeedCurve ?

Post by kavatortank »

In fact, I only want to now if the tank must turn to the left or the right.
I only have the orientation on the tank ( quaternion ), and the point where the tank must go.
I have problem with quaternion manipulation, can you help me ?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: ConstantAngularSpeedCurve ?

Post by Norbo »

In fact, I only want to now if the tank must turn to the left or the right.
I only have the orientation on the tank ( quaternion ), and the point where the tank must go.
You also have the tank's forward vector (and quite a bit of other information). The forward direction can be computed by transforming a local direction by the orientation. Or, you could grab the Forward vector right out of the OrientationMatrix representation.

Comparing the forward vector against the desired direction will give you the information needed for steering. One option would be to project the forward vector onto the horizontal plane, normalize it, and use a dot product and/or cross product with the desired direction to compute the signed angle. Another option would be to use atan2 to compute the yaw. Quaternion manipulation should not be needed.
kavatortank
Posts: 91
Joined: Tue May 14, 2013 12:17 pm

Re: ConstantAngularSpeedCurve ?

Post by kavatortank »

Hi,
I have lots of difficulties to connect the Heighmap graphical model and the physical model.
I didn't understand why, when I draw my graphical model with no transform, and when the modelDrawer draw the physcal model with no transform, models displayed with different size and position.

Help me plz
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: ConstantAngularSpeedCurve ?

Post by Norbo »

Make sure the origin of the model is the same, and make sure that the transform of the terrain collidable (which can contain any arbitrary affine transform) is consistent with the terrain graphic.
kavatortank
Posts: 91
Joined: Tue May 14, 2013 12:17 pm

Re: ConstantAngularSpeedCurve ?

Post by kavatortank »

How I can check that ?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: ConstantAngularSpeedCurve ?

Post by Norbo »

If you mean the terrain's transform, it is whatever you assigned during the terrain's construction. For example, from the TerrainDemo:

Code: Select all

            var terrain = new Terrain(heights, new AffineTransform(
                    new Vector3(xSpacing, 1, zSpacing),
                    Quaternion.Identity,
                    new Vector3(-xLength * xSpacing / 2, 0, -zLength * zSpacing / 2)));
The second parameter, the AffineTransform, defines a scale and translation.

Note that, when unscaled, the terrain's triangles are spaced 1 unit apart.
kavatortank
Posts: 91
Joined: Tue May 14, 2013 12:17 pm

Re: ConstantAngularSpeedCurve ?

Post by kavatortank »

How do I get those values ?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: ConstantAngularSpeedCurve ?

Post by Norbo »

I'm not sure what you mean; you choose xSpacing etc. yourself to produce the desired simulation behavior.

If you're asking how to access the transform later, use the Terrain.WorldTransform property.
kavatortank
Posts: 91
Joined: Tue May 14, 2013 12:17 pm

Re: ConstantAngularSpeedCurve ?

Post by kavatortank »

No, I generate my Heighmap with the content processor, and I catch heights, but how I can check xSpacing... ?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: ConstantAngularSpeedCurve ?

Post by Norbo »

It is a value that you choose. You do not need to 'check' for it, it is just a value used to create whatever transform you want.

In the example, xSpacing and zSpacing are used to create a scale factor. That scaling transform would multiply the X coordinates by xSpacing, the Y coordinates (heights) by 1, and the Z coordinates by zSpacing. The demo does this because I wanted more than 1 horizontal unit between adjacent vertices.
kavatortank
Posts: 91
Joined: Tue May 14, 2013 12:17 pm

Re: ConstantAngularSpeedCurve ?

Post by kavatortank »

In the content processor I have this :

Code: Select all

for (int y = 0; y < heightfield.Height; y++)
            {
                for (int x = 0; x < heightfield.Width; x++)
                {
                    Vector3 position;

                    // position the vertices so that the heightfield is centered
                    // around x=0,z=0
                    position.X = scale * (x - ((heightfield.Width - 1) / 2.0f));
                    position.Z = scale * (y - ((heightfield.Height - 1) / 2.0f));
                    position.Y = (heightfield.GetPixel(x, y) - 1) * bumpiness;
                    builder.CreatePosition(position);
                }
            }
To create positions.
I have a model.
Post Reply