Changeset 15554 for branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Geometry/Line3D.cs
- Timestamp:
- 12/20/17 16:15:38 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Geometry/Line3D.cs
r15488 r15554 9 9 /// A line is given as a point and a directing vector 10 10 /// </summary> 11 internalclass Line3D {11 public class Line3D { 12 12 public Vector3D Point; 13 13 public Vector3D Direction; … … 30 30 } 31 31 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> 32 38 public Vector3D Intersect(Line3D line) { 33 39 double r = 0; 34 40 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 } 35 46 36 47 if (Direction.X != 0) { … … 49 60 s = (this.Point.Z - line.Point.Z) / (double)line.Direction.Z; 50 61 } 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; 58 67 } 59 68
Note: See TracChangeset
for help on using the changeset viewer.