Unigine::JointWheel Class

This class is used to create ray-cast wheels. Both a frame and a wheel are rigid bodies. There is no need to assign a shape to the wheel: ray casting is used to detect collision of the wheel with a surface.

Example

The following code illustrates connection of two rigid bodies (frame and wheel) using a wheel joint.

Source code (C++)
``````include <UniginePhysics.h>

/* .. */

JointWheelPtr joint = JointWheel::create(frame, wheel);

// setting joint anchor coordinates
joint->setWorldAnchor(wheel->getObject()->getWorldTransform() * Vec3(0.0f));

// setting joint axes coordinates
joint->setWorldAxis0(vec3(0.0f,0.0f,1.0f));
joint->setWorldAxis1(vec3(0.0f,1.0f,0.0f));

// setting linear damping and spring rigidity
joint->setLinearDamping(200.0f);
joint->setLinearSpring(100.0f);

// setting lower and upper suspension ride limits [-1.0; 0.0]
joint->setLinearLimitFrom(-1.0f);
joint->setLinearLimitTo(0.0f);

// setting target suspension height
joint->setLinearDistance(0.5f);

// setting maximum angular velocity and torque
joint->setAngularVelocity(-20.0f);
joint->setAngularTorque(10.0f);

// setting wheel parameters
joint->setWheelMass(4.0f);
joint->setWheelThreshold(0.1f);

// setting tyre friction parameters
joint->setTangentFriction(4.0f);
joint->setBinormalFriction(5.0f);

// setting number of iterations
joint->setNumIterations(8);``````

static JointWheelPtr create()

Constructor. Creates a wheel joint with an anchor at the origin of the world coordinates.

static JointWheelPtr create(const Ptr<Body> & body0, const Ptr<Body> & body1)

Constructor. Creates a wheel joint connecting two given bodies. An anchor is placed between centers of mass of the bodies.

Arguments

• const Ptr<Body> & body0 - Frame to be connected with the joint.
• const Ptr<Body> & body1 - Wheel to be connected with the joint.

static JointWheelPtr create(const Ptr<Body> & body0, const Ptr<Body> & body1, const Math::Vec3 & anchor, const Math::vec3 & axis0, const Math::vec3 & axis1)

Constructor. Creates a wheel joint connecting two given bodies with specified suspension and spindle axis coordinates and an anchor placed at specified coordinates.

Arguments

• const Ptr<Body> & body0 - Frame to be connected with the joint.
• const Ptr<Body> & body1 - Wheel to be connected with the joint.
• const Math::Vec3 & anchor - Anchor coordinates.
• const Math::vec3 & axis0 - Suspension axis coordinates.
• const Math::vec3 & axis1 - Wheel spindle axis coordinates.

Ptr<JointWheel>cast(const Ptr<Joint> & joint)

Casts a JointWheel out of the Joint instance.

Arguments

• const Ptr<Joint> & joint - Joint instance.

JointWheel.

voidsetAngularDamping(float damping)

Sets an angular damping of the joint (wheel rotation damping).

Arguments

• float damping - Angular damping. If a negative value is provided, 0 will be used instead.

floatgetAngularDamping()

Returns the angular damping of the joint (wheel rotation damping).

Angular damping.

voidsetAngularTorque(float torque)

Sets a maximum torque of the attached angular motor.

Arguments

• float torque - Maximum torque. If a negative value is provided, 0 will be used instead.

floatgetAngularTorque()

Returns the maximum torque of the attached angular motor.

Maximum torque.

voidsetAngularVelocity(float velocity)

Sets a maximum velocity of wheel rotation.

Arguments

• float velocity - Velocity in radians per second.

floatgetAngularVelocity()

Returns the target velocity of wheel rotation.

Return value

Target velocity in radians per second.

voidsetAxis00(const Math::vec3 & axis00)

Sets coordinates of suspension axis, along which a wheel moves vertically. This is a shock absorber.

Arguments

• const Math::vec3 & axis00 - Suspension axis.

Math::vec3getAxis00()

Returns suspension axis coordinates.

Suspension axis.

voidsetAxis10(const Math::vec3 & axis10)

Sets a wheel spindle axis in coordinates of the wheel: an axis around which a wheel rotates when moving forward (or backward).

Arguments

• const Math::vec3 & axis10 - Wheel spindle axis in coordinates of the wheel.

Math::vec3getAxis10()

Returns the wheel spindle axis in coordinates of the wheel.

Return value

Wheel spindle axis in coordinates of the wheel.

voidsetAxis11(const Math::vec3 & axis11)

Sets a wheel spindle axis in coordinates of the frame: an axis around which a wheel rotates when steering.

Arguments

• const Math::vec3 & axis11 - Wheel spindle axis in coordinates of the frame.

Math::vec3getAxis11()

Returns the wheel spindle in coordinates of the frame.

Return value

Wheel spindle axis in coordinates of the frame.

voidsetBinormalAngle(float angle)

Sets a coefficient specifying how fast the optimal lateral force can be achieved. The larger this value, the more is the impulse produced by the tire.

Arguments

• float angle - Coefficient characterizing the tire lateral impulse. If a negative value is provided, 0 will be used instead.

floatgetBinormalAngle()

Returns the coefficient specifying how fast the optimal lateral force can be achieved. The larger this value, the more is the impulse produced by the tire.

Return value

Coefficient characterizing the tire lateral impulse.

voidsetBinormalFriction(float friction)

Sets a lateral (sideways) friction of the tire.

Arguments

• float friction - Lateral friction. If a negative value is provided, 0 will be used instead.

floatgetBinormalFriction()

Returns the lateral (sideways) friction of the tire.

Return value

Lateral friction.

Math::vec3getContactNormal()

Returns a normal of a point of contact with the ground, in world coordinates.

Normal.

Ptr<Object>getContactObject()

Returns an object representing the ground.

Ground object.

Math::Vec3getContactPoint()

Returns a point of contact with the ground, in world coordinates.

Return value

Point coordinates.

Ptr<Shape>getContactShape()

Returns a shape of the object representing the ground.

Return value

Shape of the ground object.

intgetContactSurface()

Returns a surface of a ground object, which is in contact.

Surface number.

voidsetCurrentAngularVelocity(float velocity)

Sets the rotation velocity for the attached wheels. For example, it allows to reset it to zero and stop the car when necessary.

Arguments

• float velocity - Angular velocity in radians per second.

floatgetCurrentAngularVelocity()

Returns the current rotation velocity of the attached wheels.

Return value

Current angular velocity in radians per second.

voidsetCurrentLinearDistance(float distance)

Sets suspension compression (i.e. the length of the suspension).

Arguments

• float distance - Suspension length in units.

floatgetCurrentLinearDistance()

Returns the current suspension compression (i.e. the length of the suspension).

Return value

Current suspension length in units.

floatgetCurrentSlipAngle()

Returns the current angle between the wheel direction and the frame direction.

Return value

Current slip angle in degrees.

floatgetCurrentSlipRatio()

Returns the current ratio of wheel spin to ground speed.

Return value

Current slip ratio in percents. 0 means that the velocities are equal. If the throttle is pressed, the value will be positive. If the brake is pressed, the value will be negative.

Sets an intersection mask for the joint.

Arguments

• int mask - Integer, each bit of which is a mask.

Returns an intersection mask of the joint.

Return value

Integer, each bit of which is a mask.

voidsetLinearDamping(float damping)

Sets a linear damping of the suspension.

Arguments

• float damping - Linear damping. If a negative value is provided, 0 will be used instead.

floatgetLinearDamping()

Returns the linear damping of the suspension.

Linear damping.

voidsetLinearDistance(float distance)

Sets a target height of the suspension.

Arguments

• float distance - Height in units.

floatgetLinearDistance()

Returns the target height of the suspension.

Return value

Target height in units.

voidsetLinearLimitFrom(float from)

Sets a low limit of the suspension ride.

Arguments

• float from - Limit in units.

floatgetLinearLimitFrom()

Returns the low limit of the suspension ride.

Return value

Low limit in units.

voidsetLinearLimitTo(float to)

Sets a high limit of the suspension ride.

Arguments

• float to - Limit in units.

floatgetLinearLimitTo()

Returns the high limit of the suspension ride.

Return value

High limit in units.

voidsetLinearSpring(float spring)

Sets a rigidity coefficient of the suspension.

Arguments

• float spring - Rigidity coefficient. If a negative value is provided, 0 will be used instead.

floatgetLinearSpring()

Returns the rigidity coefficient of the suspension.

Return value

Rigidity coefficient.

voidsetTangentAngle(float angle)

Sets a coefficient specifying how fast the optimal longitudinal force can be achieved. The larger this value, the more is the impulse produced by the tire.

Arguments

• float angle - Coefficient characterizing the tire longitudinal impulse. If a negative value is provided, 0 will be used instead.

floatgetTangentAngle()

Returns the coefficient specifying how fast the optimal longitudinal force can be achieved. The larger this value, the more is the impulse produced by the tire.

Return value

Coefficient characterizing the tire longitudinal impulse.

voidsetTangentFriction(float friction)

Sets a longitudinal (forward) friction of the tire.

Arguments

• float friction - Longitudinal friction. If a negative value is provided, 0 will be used instead.

floatgetTangentFriction()

Returns the longitudinal (forward) friction of the tire.

Return value

Longitudinal friction.

voidsetWheelMass(float mass)

Sets a mass of the attached wheel.
Notice
If g (Earth's gravity) equals to 9.8 m/s 2, and 1 unit equals to 1 m, the mass is measured in kilograms.

Arguments

• float mass - Mass of the wheel. If a negative value is provided, 0 will be used instead.

floatgetWheelMass()

Returns the mass of the attached wheel.
Notice
If g (Earth's gravity) equals to 9.8 m/s 2, and 1 unit equals to 1 m, the mass is measured in kilograms.

Return value

Mass of the wheel.

Sets a radius of the attached wheel.

Arguments

• float radius - Radius of the wheel in units. If a negative value is provided, 0 will be used instead.

Returns the radius of the attached wheel.

Return value

Radius of the wheel in units.

voidsetWheelThreshold(float threshold)

Sets a threshold difference between the wheel and ground velocities. When it is too small, the longitudinal force will be scaled down to prevent unnatural vibrations.

Arguments

• float threshold - Difference threshold. If a negative value is provided, 0 will be used instead.

floatgetWheelThreshold()

Returns the threshold difference between the wheel and ground velocities. When it is too small, the longitudinal force will be scaled down to prevent unnatural vibrations.

Return value

Difference threshold.

voidsetWheelWidth(float width)

Sets a width of the attached wheel.

Arguments

• float width - Width of the wheel in units. If a negative value is provided, 0 will be used instead.

floatgetWheelWidth()

Returns the width of the attached wheel.

Return value

Width of the wheel in units.

voidsetWorldAxis0(const Math::vec3 & axis0)

Sets suspension axis in the world coordinates.

Arguments

• const Math::vec3 & axis0 - Suspension axis in the world coordinates.

Math::vec3getWorldAxis0()

Returns the suspension axis in the world coordinates.

Return value

Suspension axis in the world coordinates.

voidsetWorldAxis1(const Math::vec3 & axis1)

Sets a wheel spindle axis in the world coordinates.

Arguments

• const Math::vec3 & axis1 - Wheel spindle axis in the world coordinates.

Math::vec3getWorldAxis1()

Returns the wheel spindle axis in the world coordinates.

Return value

Wheel spindle axis in the world coordinates.
Last update: 2018-04-26