Need to translate position to wheel rotation

Need to translate position to wheel rotation

RobH2
Advisor Advisor
1,385 Views
10 Replies
Message 1 of 11

Need to translate position to wheel rotation

RobH2
Advisor
Advisor

I have a bicycle that I've attached to a point. The point has a path constraint. I've wired the wheels x-rotation to the point's y-position. What expression can I write to translate the path's length to the radius of the wheel so it rotates at the correct speed? For simplicity, I've multiplied the 'Position' by an arbitrary trial-n-error number until it looks ok, but, it's not perfect. I'm using 'position*32' in my expression and it's pretty good, it's just not elegant. 


Rob Holmes

EESignature

------------------------------------------------------------------------------------------------------------------------------------------
3ds Max (2023-2025), V-Ray 6.2, Ryzen 9 3950-X Processor, DDR 4 128MB, Gigabyte Aorus X570 Master motherboard, Sabrent Rocket NVMe 4.0 M.2 drives, NVidia RTX 4090, Space Pilot Pro, Windows 11 Pro x64, Tri-Monitor, Cintiq 13HD, Windows 11 x64
------------------------------------------------------------------------------------------------------------------------------------------
0 Likes
1,386 Views
10 Replies
Replies (10)
Message 2 of 11

istan
Advisor
Advisor

diameter * PI = circumference = 360 degree ?

0 Likes
Message 3 of 11

RobH2
Advisor
Advisor

Hi, is this an expression you are giving me here or just telling me the math? I know the math, I just don't know how to write the expression. Your post does not appear to be maxscript so I'm assuming you are just trying to educate me on the math. I'll try it though and see if it is code but I don't think it is. 

 

Thank you


Rob Holmes

EESignature

------------------------------------------------------------------------------------------------------------------------------------------
3ds Max (2023-2025), V-Ray 6.2, Ryzen 9 3950-X Processor, DDR 4 128MB, Gigabyte Aorus X570 Master motherboard, Sabrent Rocket NVMe 4.0 M.2 drives, NVidia RTX 4090, Space Pilot Pro, Windows 11 Pro x64, Tri-Monitor, Cintiq 13HD, Windows 11 x64
------------------------------------------------------------------------------------------------------------------------------------------
0 Likes
Message 4 of 11

istan
Advisor
Advisor

Well, I though I give you the quick math only in the case you didn't see the tree for woods..

0 Likes
Message 5 of 11

Anonymous
Not applicable

G;day

 

I'm assuming you have linked one wheel to the point so that when you scrub the time line the wheel follows the point around your path.

 

I so then create a Rotational Float expression on the wheel in the x direction and add this expression:

 

(PathLength*Percent)/WheelRadius

 

 

Create Scalar values for

 

   Percent  =  select the  Point Pos List.Path Constraint.Percent:Linear Float


    PathLenght = Lenght of path (you need to measure this)


    WheelRadius = radius of wheel

 

As your point travels along the path, the wheel will rotate.

 

Hope this helps

 

0 Likes
Message 6 of 11

denisT.MaxDoctor
Advisor
Advisor
with redraw off
(
	delete objects

	spinAttrib = attributes "spinAttrib"
	(
		parameters main 
		(
			lastTM type:#matrix3 animatable:off
			angle type:#float animatable:off
		)
	)
	fn makeWheel name: radius: pos: wirecolor: = 
	(
		in (p = point name:name pos:pos size:10 wirecolor:yellow)
		(
			w = cylinder name:(name + "_body") sides:24 segments:1 radius:radius height:3 slice:on sliceFrom:350 sliceTo:10 pos:pos wirecolor:wirecolor
			w.objectOffsetRot = eulerangles 90 0 0
			CenterObject w
		)
		p
	)
	mapped fn makeWheelScript p =
	(
		node = p.children[1]
		
		ss  = "tm = parent.transform*(inverse this.lastTM)\n" 
		ss += "sign = (if dot tm[1] this.lastTM[1] > 0 then 1 else -1)\n" 
		ss += "this.angle += 360*tm.pos.x*sign/(2*pi*radius)\n"
		ss += "this.lastTM = parent.transform\n"
		ss += "degtorad(this.angle)\n"

		c = node.rotation.controller[2].controller = float_script()
		custattributes.add c spinAttrib
		c.lastTM = p.transform
		c.addconstant "radius" node.radius
		c.addnode "parent" p
		
		c.setexpression ss
		c
	)
	body = 
	(
		b =  (box name:"Wheel_chair" width:25 length:20 height:25 pos:[-5,0,17] wirecolor:blue) - (c = box width:30 length:25 height:25 pos:[0,0,25])
		delete c
		b
	)
	local wheels = #(), look
	in body 
	(
		look = point name:"Dir_Dummy" size:10 axistripod:on box:on pos:[15,0,5] wirecolor:green
			
		append wheels (makeWheel name:"LF_wheel" radius:5 pos:[10,-10,5] wirecolor:red)
		append wheels (makeWheel name:"RF_wheel" radius:5 pos:[10,10,5] wirecolor:red)
		append wheels (makeWheel name:"LR_wheel" radius:15 pos:[-10,-13,15] wirecolor:orange)
		append wheels (makeWheel name:"RR_wheel" radius:15 pos:[-10,13,15] wirecolor:orange)
	)	
	makeWheelScript wheels
	c = Orientation_Constraint local_world:2
	c.appendTarget look 100
	wheels[1].rotation.controller = wheels[2].rotation.controller = c
	
	in coordsys local with animate on
	(
		at time 30 move body [60,0,0]
		at time 30 rotate body (eulerangles 0 0 0)
		at time 40 rotate body (eulerangles 0 0 -40)
		at time 40 move body [15,5,0]
		at time 70 move body [80,0,0]
		at time 70 rotate body (eulerangles 0 0 0)
		at time 80 rotate body (eulerangles 0 0 -40)
		at time 100 move body [-100,0,0]
	)
	
	select body
)

here is an example i made for another people on another forum. Hope it might help

 

0 Likes
Message 7 of 11

vivastudio
Explorer
Explorer

Hello all! Can anyone help, I am doing this design, furniture wheel.
https://www.youtube.com/watch?v=j1AZTvBaNR0
But when I turn it 180, the wheel starts spinning the other way.
Apparently I need to make a correct expression, but I do not know how.

0 Likes
Message 8 of 11

RobH2
Advisor
Advisor

I will look at your file and see if I can spot something obvious. I'm not a script writer. The guys above are good with that. As I read this post, I realize I didn't even come back and thank them for the assistance. Their answers led me to a good solution, so, "thanks guys in retrospect..."

 

It looks like all you need to do is find the parameter that tells the wheel to change rotation direction based on the linear vector of the helper it's following. It appears you followed the video you posted. Maybe you missed a step. What about going through that whole video again with your file open and just double check everything?


Rob Holmes

EESignature

------------------------------------------------------------------------------------------------------------------------------------------
3ds Max (2023-2025), V-Ray 6.2, Ryzen 9 3950-X Processor, DDR 4 128MB, Gigabyte Aorus X570 Master motherboard, Sabrent Rocket NVMe 4.0 M.2 drives, NVidia RTX 4090, Space Pilot Pro, Windows 11 Pro x64, Tri-Monitor, Cintiq 13HD, Windows 11 x64
------------------------------------------------------------------------------------------------------------------------------------------
Message 9 of 11

leeminardi
Mentor
Mentor

Perhaps this thread will provide some help.

lee.minardi
Message 10 of 11

vivastudio
Explorer
Explorer

Hello!
I do not have the file, the one in the attachment is my version, I made it based on the video.
But the main point there - wrong rotation of the wheel after inertial rotation by 180.
For this you need a script!
I just do not write a script myself and do not know how to properly make the expression, so that at certain angles of rotation of the wheel was a certain direction of rotation.

0 Likes
Message 11 of 11

vivastudio
Explorer
Explorer

Oh! Thank you so much! I think this is very close to my problem!

0 Likes