Sign in to follow this  
takis

Finding the "crossed edge"

Recommended Posts

Hello, I am trying to create particle repulsion on a 3d mesh with Greg Turk. " Making the points repel one another becomes straightforward once we can map nearby points onto a given point’s plane. For each point P on the surface we need to determine a vector S that is the sum of all repelling forces from nearby points. The new position for the point P on polygon A will be P’ = P + kS, where k is some small scaling value. In many cases the new point P’ will lie on A. If P’ is not on A, it will often not even lie on the surface of the polyhedron. In this case, we determine which edge of A that P’ was “pushed” across and also find which polygon (call it B) that shares this edge with A. The point P’ can be rotated about the common edge between A and B so that it lies in the plane of B. This new point may not lie on the polygon B, but we can repeat the procedure to move the point onto the plane of a polygon adjacent to B. Each step of this process brings the point nearer to lying on a polygon and eventually this process will terminate. " I find the nearest edge as listing below. But if i run Turks alg, it sometimes comes in a infinite loop. I know the reason of this error. it has something to do with finding the nearest edge. If it is not in polygon A, it tests polygon B. But then he says the edge nearest to the new point is the edge that shares polygon A. So back to A and then back to B etc... Does anyone knows a better solution? Another question is to rotate all nearby points to a given point's plane. I rotate all nearby points around the nearby edge so the lay in the given plane. Is there a more simple solution for this? // returns nearest point on a line segment [a,b] Vector3D Vector3D::nearestPoint(const Vector3D& a, const Vector3D& b, const Vector3D& p) { // see if a is the nearest point float dot_ta=Vector3D::dotProduct(p-a, b-a); if(dot_ta<=0.0f) return Vector3D(a); // see if b is the nearest point float dot_tb=Vector3D::dotProduct(p-b, a-b); if(dot_tb<=0.0f) return Vector3D(b); // nearest point on line segment float x=a[0]+((b[0]-a[0])*dot_ta)/(dot_ta+dot_tb); float y=a[1]+((b[1]-a[1])*dot_ta)/(dot_ta+dot_tb); float z=a[2]+((b[2]-a[2])*dot_ta)/(dot_ta+dot_tb); return Vector3D(x,y,z); }

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this