Magnets

Posted By: A.Russell

Magnets - 09/02/04 11:04



I want to have a magnetic rotating cylinder that balls will stick to when they get close. Does anyone have any ideas how to attack this?
Posted By: GhostDude

Re: Magnets - 09/02/04 12:11

You could use a scan_entity() to determine if an attractable object is close, then use phent_addcentralforce or something like that to move the object.
Posted By: fastlane69

Re: Magnets - 09/02/04 13:23

Another option might be to use the ph_slider. When the ball comes close to the magnet, you attach the constraint. You can then adjust the motor 1 parameter to simulate attraction and rejection and release the constraint when it goes outta range. The manual says that other movement is blocked so this might not work for the kind of magnetic motion you want.
Posted By: A.Russell

Re: Magnets - 09/02/04 13:32



How about if I change the ball's gravity to the centre of the cylinder when it comes within range?

I'm not sure how then it would rotate with the cylinder, though.
Posted By: A.Russell

Re: Magnets - 09/02/04 21:21

No, that wouldn't work. Gravity is global. I'll your suggestions. Thanks.
Posted By: Alexander Esslinger

Re: Magnets - 09/03/04 00:11

Not sure how a "magnetic rotating cylinder" looks like or works, but if you know how it works, you can add the corresponding forces to your ball-objects via add_force().
Posted By: BHoltzman

Re: Magnets - 09/04/04 05:47

If you don't need this to be interactive then it's very easy to set up an animation of the balls sticking to a magnetic cylinder. You can even use hook's law so the balls can build a chain that is effected by inertia and other forces you may want to introduce. Also the balls would be able to detect self collisions so they won't go through each other.

If this needs to be interactive then I don't know how to solve it. The latest beta messes up physics on my computer. But it's got some important physics functions like the iteration control and the physics auto off feature. I know I messed up the names but I'm hoping you know what I'm talking about.

Anywho, it's probably worth while to wait for these functions to work in the physics system.
Posted By: A.Russell

Re: Magnets - 09/04/04 12:07


I'm going for the interactive approach. Here's a simple illustration to help explain the effect:



I'm also still using 6.22.

I'd like to learn more about "hooks law". How does that work?
Posted By: BHoltzman

Re: Magnets - 09/04/04 14:04

Sure, Hooks law is a rule for particle simulation that makes the particles reach out from or away from a goal by hooking particles onto each other. It looks like how a strong magnetic field makes a series of metal objects stick to each other. It's a cool effect to watch. I'm only familiar with it through XSI. But if you're thinking of trying to simulate it interactively, I'm not sure how to help you.

I'll look for information on the technical aspect of it if you're interested. Or if you'd like me to email you an animation of hook's law in action, I can do that for you too.

EDIT: I did a google search and found a simple physics example showing Hook's law. It doesn't look terribly complicated. You take a look and see what you think.

http://www.suremath.com/suremath/suremath/kinDir/springW.html
Posted By: A.Russell

Re: Magnets - 09/05/04 17:53

Gosh, that's very complicated. It would be like writing an extention for the physics engine. I was hoping for something simpler, like a local gravity using the curent physics engine, though it doesn't seem possible.
Posted By: GhostDude

Re: Magnets - 09/06/04 10:46

I must be thinking of a different Hook's law...

All you have to do is this: give the magnet an action that keeps scanning around it for physics entities. You can use events like event_scan and event_detect, and a flag to show which entities are physics entities. Then, if one gets close enough to the magnet, use forces to push the ball at the magnet... phent_addcentralforce, etc.

It would have to be a pretty strong force to overcome other forces + gravity... also, magnetic attraction grows stronger the closer the 2 objects become, just something to keep in mind for realism...
Posted By: BHoltzman

Re: Magnets - 09/06/04 13:54

I'll admit I didn't look very carefully at Hook's law. But it seems like it's just an algebraic expression. XSI does this rule in simulation in real time so it's not impossible to make it work in real time. Then again it may have taken a mathematician to figure out how to do Hook's law in real time. I really have no idea.
© 2024 lite-C Forums