Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/20/17 16:15:38 (6 years ago)
Author:
rhanghof
Message:

#2817:

  • Unittests
  • Bugfixes on the line projection based extreme point creation method
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Geometry/Line3D.cs

    r15488 r15554  
    99  /// A line is given as a point and a directing vector
    1010  /// </summary>
    11   internal class Line3D {
     11  public class Line3D {
    1212    public Vector3D Point;
    1313    public Vector3D Direction;
     
    3030    }
    3131
     32    /// <summary>
     33    /// Returns the intersection point of two lines.
     34    /// It the lines doesn't intersect it returns null.
     35    /// </summary>
     36    /// <param name="line"></param>
     37    /// <returns></returns>
    3238    public Vector3D Intersect(Line3D line) {
    3339      double r = 0;
    3440      double s = 0;
     41
     42      // if they have the same source point, this point can be returned.
     43      if (this.Point.Equals(line.Point)) {
     44        return this.Point;
     45      }
    3546
    3647      if (Direction.X != 0) {
     
    4960        s = (this.Point.Z - line.Point.Z) / (double)line.Direction.Z;
    5061      }
    51 
    52       var a = r * this.Direction + this.Point;
    53       var b = s * line.Direction + line.Point;
    54       var c = a.Equals(b);
    55       if (s!=0 && r!=0 && a.Equals(b)) {
    56        
    57         return a;
     62      var p1 = r * this.Direction + this.Point;
     63      var p2 = s * line.Direction + line.Point;
     64      var c = p1.Equals(p2);
     65      if (s!=0 && r!=0 && p1.Equals(p2)) {       
     66        return p1;
    5867      }
    5968
Note: See TracChangeset for help on using the changeset viewer.