Anim8or Community

Please login or register.

Login with username, password and session length
Advanced search  


An update to Anim8or, v1.00b, is available with a few bug fixes. Get your copy HERE. See the "ReadMe" file for details.

Author Topic: New function: Intersect edges  (Read 3817 times)


  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • Cume Software official website
New function: Intersect edges
« on: April 04, 2008, 12:51:00 pm »

I don't knew of this would be an useful addition, but by my experience with anim8or I'm in need of a function that finds the intersection point of two unlinked and intersecting edges. The function would first evaluate if the edges intersect. For that, we have to see if all points are coplanar, and case positive, if the lines actually do intersect at a point. Case yes, the function would merge the edges by the intersection point.

This functions is practical when we want to calculate exact intersections to cut an object, when the cut faces function is not appropriate. This is only one example where such function would be handy. There were other situations where I add to calculate the intersection points by hand.

I have a C code to determine if 4 points (from the edges) are coplanar:
Code: [Select]
bool IsCoplanar (double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3) const
    return x0 * (y1 * (z2 - z3) - z1 * (y2 - y3) + y2 * z3 - z2 * y3)
    - y_ * (x1 * (z2 - z3) - z1 * (x2 - x3) + x2 * z3 - z2 * x3)
    + z_ * (x1 * (y2 - y3) - y1 * (x2 - x3) + x2 * y3 - y2 * x3)
    - x1 * (y2 * z3 - z2 * y3)
    + y1 * (x2 * z3 - z2 * x3)
    - z1 * (x2 * y3 - y2 * x3) == 0;
This code was adapted from a 3D point class I've made in C++. I still don't have the other two required functions figured out.