Jump to content

Math Question


Pryme8
 Share

Recommended Posts

Im trying to find the shortest length vector between two vec2's for my tutorial im writing up...

function project(a, b){
 var proj = new Array(a.length);
  var  bt = 0;
   for(var i = 0; i < a.length; i++){
    bt+= (b[i]*b[i]);
   }
   for(var i = 0; i < a.length; i++){
    proj[i] = (dot(a,b)/bt)*b[i];
  }
return proj
}

 

Any one know if this is correct or have any good websites that go over it?  Im having trouble finding good documentation on what Im trying to explain... I mean I get it in my head but being able to communicate that to someone else is rather hard.

Link to comment
Share on other sites

I'm working on a pretty extensive tutorial right now, showing how to deploy web workers as a underlying physics engine for a custom canvas.  And I got to the collision testing part and realized that even though I know how to do it I had no clue how to properly explain it which made me think that maybe I don't know it as well as I though and so Ive been read read reading...

I needed to learn web workers to increase calculation time on my Das Noise Library, and to make it when i launch the  TERIABLE Demo all the calculations/procedural I/O crunching will happen on a sub thread to make everything flow better.

And then somehow a web worker tutorial now has slowly turned into a Calculus lesson for estimating logarithmic pseudo distance...

this is the part I just wrote o_O:

"This is where the method for separating axes comes into play. If you look at our diagram on the right you will see two polygons. Both of these shapes are called Convex Shapes. A Convex shape is any polygon that can be defined by a set of points, that if you were to draw a straight line anywhere on the shape from one point to another on the polygon, the line will never travel outside of the shape. Anyways these two Convex polygons are in a non intersecting state.

The value for the separation is positive and so we know that the shapes are not touching, if it was negative the shapes would be overlapping and if it was 0 the shapes are just touching. With this kind of hit detection there would be three kinds of possible contact, edge to edge, vertex to edge, and vertex to vertex. If we were to draw a line between the two polygons and pretend the separation line continues to infinity and then draw a line perpendicular to this line, that is our separation axis."

Im up to 23 pages >_< and just got through basic terminology and calculations... this turned into a way bigger project then I intended... but I see the information as super super valid cause I'm digesting what PHD people are saying and try to break it down in a more simplistic way for the masses of us that did not go to college for Math.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...