Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate Membrane Mesh With Proteins #26

Open
2 of 10 tasks
thejmazz opened this issue Apr 21, 2016 · 9 comments
Open
2 of 10 tasks

Populate Membrane Mesh With Proteins #26

thejmazz opened this issue Apr 21, 2016 · 9 comments

Comments

@thejmazz
Copy link
Owner

thejmazz commented Apr 21, 2016

  • populate membranes with proteins that have defined TM-Section material
  • move linearly through verts
  • move randomly through verts
  • move through faces
  • filter by face normals threshold
  • filter by face normals average
  • avoid edges
  • list of proteins
  • different densities for each protein
  • different proteins on inner and outer side

Given a membrane mesh and a list of proteins, populate the membrane mesh

  • no intersections
  • settings for filling all possible space, amount of space filled, different densities for different proteins

Given a (relatively) arbitrary geometry:

  • sphere
  • section of sphere
  • curved plane (red)
  • plane with "noise" around edges (blue)
  • "arbitrary" (grey)

screen shot 2016-04-20 at 11 55 50 pm

we would like to populate it with non-intersecting protein meshes. These can be simplified to their bounding box.

@thejmazz
Copy link
Owner Author

thejmazz commented Apr 21, 2016

Some visual examples of the goal:

cell membrane copy

With the membrane highlighted, and an example protein bounding box drawn.

@thejmazz
Copy link
Owner Author

thejmazz commented Apr 21, 2016

Using a 2D Array to keep track of available spots

600-700ms for a 100x100 grid filled with 4x4 proteins

This is what a simple membrane with simple proteins will look like once populated:

screen shot 2016-04-20 at 11 27 18 pm

[implemented here with 2D true/false array to keep track of available spaces](https://github.com/biorender/biorender/blob/77e695065904ed3e26e746523599537dfb92da0f/membrane-playground/src/index.js#L125-L215)

@thejmazz
Copy link
Owner Author

thejmazz commented Apr 21, 2016

Using Rays and Checking for Object intersections

Tried this. Took 22 secs to test 8 rays (vertices of a cube) for placing a cube on plane. Not scalable, at least without some octrees or other filtering methods, but the 2D array method was much faster.

@thejmazz
Copy link
Owner Author

Using a Tree Based Structure

See Tree-based Data Structures for Triangle Mesh Connectivity Encoding

There will be as many nodes as there are faces in the mesh. Each iteration will pick a random face, check if that protein can fit there, if it can, assign true to the proper nodes, else, try another face. Go until no more faces available or a desired percentage of faces filled.

Similar to 2D array method, tree of nodes can have true/false values. This assumes the protein will stick vertically with the normal against the polygon face, and then not intersect with proteins around it. Which is an ok assumption, is largely true.

A complication is assigning multiple faces at once.

@thejmazz
Copy link
Owner Author

Use overlap from BVH tree in Blender

How to check if two meshes intersect in python with BVH Tree?

Same as ray intersecting approach, but in Blender.

@thejmazz
Copy link
Owner Author

thejmazz commented Apr 21, 2016

@thejmazz
Copy link
Owner Author

thejmazz commented Apr 21, 2016

Goblin

goblinphysics

const goblinBox = new Goblin.RigidBody(new Goblin.BoxShape(2,3,2))
goblinBox.position = new Goblin.Vector3(0, 0, 0)
goblinBox.updateDerived()
let collidee, contactDetails

console.time('goblinRunNoCollision')
collidee = new Goblin.RigidBody(new Goblin.BoxShape(2,3,2))
collidee.position = new Goblin.Vector3(10, 0, 0)
collidee.updateDerived()
contactDetails = Goblin.GjkEpa.testCollision(goblinBox, collidee)
console.log(contactDetails === undefined ? 'No Collision' : 'Collision')
console.timeEnd('goblinRunNoCollision')

console.time('goblinRunWithCollision')
collidee = new Goblin.RigidBody(new Goblin.BoxShape(2,3,2))
collidee.position = new Goblin.Vector3(2, 0, 0)
collidee.updateDerived()
contactDetails = Goblin.GjkEpa.testCollision(goblinBox, collidee)
console.log(contactDetails === undefined ? 'No Collision' : 'Collision')
console.timeEnd('goblinRunWithCollision')

Which gives times like this:

screen shot 2016-04-21 at 6 35 16 pm

Without console.log it is much faster, left out of the tests from here on:

screen shot 2016-04-21 at 6 36 44 pm

But, I just want binary information: Did a collision occur, yes or no?. So, we can strip out the extra EPA based collision details by changing testCollision to take a boolean param binary to decide whether or not to invest time to running Goblin.GjkEpa.EPA(simplex):

testCollision: function( object_a, object_b, binary ) {
       var simplex = Goblin.GjkEpa.GJK( object_a, object_b );
       if ( Goblin.GjkEpa.result != null ) {
               return Goblin.GjkEpa.result;
       } else if ( simplex != null ) {
         if (!binary) {
           // console.log('Only wants binary information')
           return Goblin.GjkEpa.result;
        } else {
           // console.log('Wants EPA info')
          return Goblin.GjkEpa.EPA( simplex );
         }
       }
},

This brings collision times to be even lower than no collisions!

screen shot 2016-04-21 at 6 43 34 pm

@thejmazz
Copy link
Owner Author

thejmazz commented Apr 22, 2016

10000 verts, GJK on every box added so far box, ~~~12 seconds~~~ 800-1000ms with octree and less object instanciation
screen shot 2016-04-21 at 10 49 52 pm

@thejmazz
Copy link
Owner Author

Almost done
screen shot 2016-04-24 at 4 42 01 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant