1
$\begingroup$

For a physics engine I am working on, I need to know two object's friction coefficient (for bouncing, collision detection, friction in general etc.). Since this physics engine will have lots of different materials, it would be inefficient to have a list of every pair of materials, with their friction coefficient. So, I would like to know if there is any value I can assign to each material, which would mean I could work out the friction coefficient between the two objects, using the two material's values.

$\endgroup$
7
  • $\begingroup$ I'm unable to find any mixing rules (and I'd be very surprised if they did exist). Have you considered just offering a few material classes? e.g. metal, rubber, plastic, etc $\endgroup$
    – lemon
    Feb 10, 2015 at 21:01
  • $\begingroup$ @lemon The problem with only having a few material classes is it completely rules out the other side to my physics engine (which I didn't mention), which is the chemistry aspect, and I would feel disappointed if the only thing the chemistry side of my engine can do is distillation of water and making esters or something $\endgroup$
    – Orfby
    Feb 10, 2015 at 21:15
  • $\begingroup$ I just meant that when you assign a friction coefficient you do so based on the material class. Each object can still have a more specific material assigned to it which could then be used for more specific chemical interactions. $\endgroup$
    – lemon
    Feb 10, 2015 at 21:21
  • $\begingroup$ @lemon I see, so lots of materials can be under the same class, so they share a friction coefficient, but aren't the same in every other way. Assuming no one else has a better idea, I might just use that system. $\endgroup$
    – Orfby
    Feb 10, 2015 at 21:25
  • 1
    $\begingroup$ Consider also that the coefficient of friction is not only dependent on the material, but also the surface finish. I think you should think of a way to simplify, like the ones mentioned above. $\endgroup$
    – Brionius
    Feb 10, 2015 at 21:35

1 Answer 1

0
$\begingroup$

There are no simple "mixing" rules for defining pretty much any aspect of the physics of composite materials. Materials science is not that simple: chemical bonding of the same elements is radically different in different combinations.

I think adding a new object to running code through the Factory Pattern for each and every new material you need is a pretty standard method in all kinds of simulation software from EM materials to optical glasses to mechanical properties of materials, whether it be a numerical analysis or design software, whether commercial or research grade. See:

Gamma, Helm, Johnson and Vlissedes,"Design Patterns: Elements of Reusable Object-Oriented Software"

and read about the Factory Pattern - you REALLY need to see this before attempting building code like what you thinking of. Once you have built your "factory" in software, you then either link in prototype objects for the factory from a DLL or other library or encode and read them from, say, an XML file at startup. There are sample codes in the book, and the factory classes are a page of code at the most.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.