subprotocol/verlet-js

Collision and Area Constraints

formula1 opened this issue · 3 comments

I don't know how dead this project is but I believe it has a lot of potential.

A lot is still broken. But I'm hoping that I could get some help and/or merge at some point.

Amoungst my problems are

  • Why are my collisions sliding into eachother?
  • How do I detect negative area?
  • When I get negative area, am I supposed to making the distances between the points smaller or attempt to switch sides?

Alot of my math is done on pen and paper and then applied to the engine. I can show as much as need be if you'd like to help. Some of it I've written inline for others to double check if need be.

Again: At some point I want to merge back to the main repository but of course that is only if you are willing. I've made many changes, some of which are breaking changes and to be honest more will be coming in the future.

Right now the breaking changes are

  • Vec2's are mutable by default. They require the person to create a copy with .clone() if they don't want them to be. This was done because of a delaunay algorithm I was initially using. Though I'm no longer using it, I wouldn't doubt I may do it again if it helps my blob.

Some other changes I may play with in the future

  • Make certian properties cached - this is mostly in my line, AABB, triangle and polygon. However it may be slower so I'm not 100% sure yet
  • store sorted lists of particles - Tests so far have told me its actually slower, however, it does not account for lists that have already been somewhat sorted. However, the sorted lists will almost only be used for calculating collisions so it might not be worth it
  • Breaking Change Make Constraints return a transform rather than directly changing velocity of the point
  • Breaking Change Use a math library to avoid floating point error as much as possible such as big number. This will cause many math calculations to be wrong unless you use the library
  • Change all for( a in array) to while(length--) and eventually .foreach() once chrome gets its act togethor- http://jsperf.com/for-vs-foreach/268
  • Look up more jsperf statistics such as vec2 as typed array or component
  • attempt to borrow algorithms from other blobs blobgame (box2d) and volume joint (@dmurph is a boss btws)

Wow, I love the blobs!! So cool! Verlet-js is not dead, but it hasn't been active mainly because I've been busy with other things--work and a kid, aka life. So many fun things to program, so little time to do them all =)

I would absolutely welcome your work landing on master. I would not worry about making breaking changes, we can make it version 2.0. So feel free to hack things apart as needed!

I really didn't think you were going to respond so fast ^____^

Its good to hear I can do whatever I please, I'll look elsewhere for help or continue as I've been doing it. There really is so much awesome stuff you can do here, it can be overwhelming for me. Thanks for the message back, hopefully you will get to see some beautiful blobs soon

An update but not really:

I still work on this on my off times, however I am still on the same problems before. A freind of mine explained to me that because I don't have a model, I have nothing to base the physics off of. So the model I think makes sense is the following

  • we have a level
  • The fulcrum is at the point that will be intersecting the line
  • the bar of the lever has no weight, only the two points on either side

Maybe thats farfetched : /