0
$\begingroup$

At the outset I warn that I don't know if absolute movement is the correct term.

What I want to show with the image below, is that it moves in 2 axes. So I want to know how to add these 2 variations of the movements of X and Y:

enter image description here

The image above shows a very simplified movement. What I'm doing in Blender is more like an F1 car going around a circuit.

I own a car and would like the wheels to rotate based on the amount of motion the chassis goes through.

As you may already know, depending on which direction the car is going, this defines whether the rotation will be clockwise or counterclockwise.

To get around this, I used an if, which will make the rotation movement always in one direction.

Expression (driver x rotation of wheel):

angle+pi/10 if varX*varY > 0 else angle+pi/10
  • angle = rotation on the x axis of the wheel itself being affected.
  • varX = x location of car (parent)
  • varY = y location of car (parent)

That's not my problem, it happens that this car travels a path, and it doesn't do it all at a constant speed, but the wheels always rotate at the same speed (because in the sum, I used a constant value).

I would like to know how to calculate the total movement, of X and Y, to use it in the rotation of the wheels.

As I'm not an English speaker I don't look for the exact term, but I believe there is a way to calculate this displacement, so that I can multiply the value of this displacement in my expression.

(angle+pi/10)*totalMovement

I tried to add a driver linked to the offset of the path, but it didn't work, I think maybe it has nothing to do with one thing with the other. I can't do this using the X and Y variations, because they give a very large value and that apparently doesn't make sense (I multiplied varX by varY).

$\endgroup$
3
  • $\begingroup$ If you know about physics, accurately describe the movement of the car is extremely hard. But you can get a approximate result. The velocity and acceleration of the car is depends on instantaneous angular velocity of the wheel. $\endgroup$
    – X Y
    Commented Mar 22, 2022 at 23:04
  • $\begingroup$ @XY Can I find the angular velocity through which variable/constant? $\endgroup$ Commented Mar 23, 2022 at 0:48
  • $\begingroup$ Notice the unit of rotation in blender is radians not degrees. $\endgroup$
    – X Y
    Commented Mar 23, 2022 at 18:17

1 Answer 1

1
$\begingroup$

If you want to get total movement of the car depends on the wheel:

Under an ideal state (ignore air resistance, any friction, vertical rotation of the wheel, ...)

$$ d_{istance} = 2r\theta^r $$ where $r$ is radius of wheel, $\theta^r$ is total radians of the wheel.

In python expression:

oj = bpy.data.objects["wheel"]
rotation_euler = oj.rotation_euler
di = oj.dimensions
# suppose wheel rotation in x axle, wheel thickness less than diameter
# So your driver expression should be:

max(di.x, di.y, di.z)*rotation_euler.x

If you want to get total rotation according to the car travel distance: first you need get the total distance:

suppose the car control by keyframe, here is the script to get the total travel distance:

import bpy

car_name = "Cube"
start_frame = 1
last_frame = 60
current_frame = bpy.context.scene.frame_current

oj = bpy.data.objects[car_name]
loc = oj.location
travel = 0

bpy.context.scene.frame_set(start_frame)
last_loc = loc.copy()

for r in range(start_frame + 1, last_frame + 1):
    bpy.context.scene.frame_set(r)
    travel += (loc - last_loc).length
    last_loc = loc.copy()

print("Travel: ", travel)

bpy.context.scene.frame_set(current_frame)

So, the driver expression of the wheel if the car have a constant speed:

travel/diameter*frame/last_frame 
$\endgroup$
1
  • $\begingroup$ Very grateful, but it would be the other way around. I would like the wheel to rotate based on the car's motion. Would the application be the same? If this way is too complicated, you don't need to edit, I'll find a way to do it the way you said. $\endgroup$ Commented Mar 23, 2022 at 22:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .