Notifications
Clear all

[Closed] How to limit the position of an object within a circle?

 wsz

How to limit the position of an object within a circle?

I was trying to use some mathematical formulas, but is giving error.

(posx ²) + (posy ²) = (radius²)

where,

maximum position of posx ² should be (radius ²) – (posy ²)

and

maximum position posy ² should be (radius ²) – (posx ²)

I am using Float Limit in X and Y position, with Float Script in each.

for example,

R = 50

If the value of x is equal to 15, the maximum value of y can only be 35.

If the value of y is equal to 25, the maximum value of x can only be 25.

ERROR: Circular Dependency

20 Replies

As far as I’ve tested,the limit controller is only good for lineal limits, I tried long ago to use math for a radial limit with this ‘float limit controller’, and it failed not because of circular dependecy, but because it gets the values without a consistent order(x,y,z), and the result was that it shaked a lot. but I think, I gonna try again…

why are you trying to limit both axes, though?

If you limit one axis, you automagically limit the other.

I.e. if the radius is 100 units, and you limit the X axis to -100 … 100.
And you limit the Y axis to -(sqrt(100^2 – xPos^2)) … (sqrt(100^2 – xPos^2))

Then at xPos = 100, yPos will be zero.
at xPos = 50, yPos will be 86.6025.
conversely, if you were to try to set the yPos to 86.6025, that position is only ever valid for an xPos = 50.

This presumes you meant limiting the position within that circle as far as user interaction goes.
Attached file is 3ds Max 2008 – if you need one for r8 / r9, I can re-create it. But it’s essentially just putting the equations above into the appropriate limits.

If you have scripts that interact with yPos, then that script will have to calculate the appropriate xPos itself. Otherwise you do indeed get a circular dependency (at least with this construction)

Here’s another solution, that uses a target node and a normalized vector to produce a slightly more flexible result in the viewports.

If you wanted to constrain to the circle’s perimeter, rather that the area, you would just use the second line in the the position script.

It also works in 3 dimensions. If you wanted to limit it to 2, just multiply the final result by [0,0,1] (or your chosen axis)

 wsz

ZeBoxx2

It was therefore much more easily than I was doing.
But because that sphera has a kind of snap in posx?

Only failed to use the Freeze Transform in sphera, because without it when I make a link in the circle of sphera, he is confused when I move the circle after the link.

Thanks!

Davestewart

I had already tried with the Taper, but only restricting its Length.

Thanks also!

1 Reply
(@zeboxx2)
Joined: 11 months ago

Posts: 0

It ‘appears’ to snap to X because moving the sphere in X will limit Y, while moving in Y does not directly (only inherently) limit X. So when you move the sphere outside of the circle (the radius), any values of X < -radius and X > radius will cause the Y value to be zero, regardless of the Y position you’re trying to set it to.

Davesterwart’s method is much more flexible and doesn’t have this apparent ‘snapping’ behavior, but does require that you tell the user to manipulate a node other than the node you’re actually limiting. There might be a way around that, as well – not too sure

Yeah – it would be cool. It’s the sort of thing you could waste hours on trying though!

Hi

Can I get the scene compiled for max9 please? I am very interested in your solution.

David

You could just use an HI IK chain on a couple of bones + nub, each bone length 1/2 radius. The nub is constrained to the sphere, (or circle, if you lock the goal in Z)

doh, dont work on max 8.

Any chance of a quick overview on how you have set this up?

which method are you going for?

Page 1 / 2