Pryme8 Posted August 27, 2016 Share Posted August 27, 2016 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. Quote Link to comment Share on other sites More sharing options...
JohnK Posted August 27, 2016 Share Posted August 27, 2016 If by vec2s you mean position vectors then the length between them is just the distance between the two points, which is (b - a).length. But I am not sure this is what you mean. Quote Link to comment Share on other sites More sharing options...
slipstart Posted August 27, 2016 Share Posted August 27, 2016 Perhaps if you gave us an example of what you were trying to do it would be easier to understand. It almost looks like you are trying to find a new vector from one to another. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 28, 2016 Author Share Posted August 28, 2016 ita for collision detection stuff, it's the shortest vector distance that the point needs to travel in to not be in collision. Is what I'm trying to work out. I want to do projection collision detection. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 28, 2016 Author Share Posted August 28, 2016 Figured it out... found a good web book. Quote Link to comment Share on other sites More sharing options...
adam Posted August 28, 2016 Share Posted August 28, 2016 Please provide the link to the web book. Thanks Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 28, 2016 Author Share Posted August 28, 2016 https://books.google.com/books?id=TnwZBwAAQBAJ&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false adam 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 28, 2016 Author Share Posted August 28, 2016 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. Nabroski and dbawel 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.