Changeset 15488 for branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Geometry
- Timestamp:
- 11/28/17 16:10:31 (7 years ago)
- Location:
- branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Geometry
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Geometry/Line3D.cs
r15454 r15488 29 29 return plane.Intersect(this); 30 30 } 31 32 public Vector3D Intersect(Line3D line) { 33 double r = 0; 34 double s = 0; 35 36 if (Direction.X != 0) { 37 r = (line.Point.X - this.Point.X) / (double)Direction.X; 38 } else if (Direction.Y != 0) { 39 r = (line.Point.Y - this.Point.Y) / (double)Direction.Y; 40 } else if (Direction.Z != 0) { 41 r = (line.Point.Z - this.Point.Z) / (double)Direction.Z; 42 } 43 44 if (line.Direction.X != 0) { 45 s = (this.Point.X - line.Point.X) / (double)line.Direction.X; 46 } else if (line.Direction.Y != 0) { 47 s = (this.Point.Y - line.Point.Y) / (double)line.Direction.Y; 48 } else if (line.Direction.Z != 0) { 49 s = (this.Point.Z - line.Point.Z) / (double)line.Direction.Z; 50 } 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; 58 } 59 60 return null; 61 } 31 62 } 32 63 } -
branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Geometry/Vector3D.cs
r15454 r15488 6 6 7 7 namespace HeuristicLab.Problems.BinPacking3D.Geometry { 8 internalclass Vector3D {8 public class Vector3D { 9 9 10 10 public int X { get; set; } … … 23 23 Z = pos.Z; 24 24 } 25 26 public PackingPosition ToPackingPosition(int assignedBin) { 27 return new PackingPosition(assignedBin, X, Y, Z); 28 } 29 25 30 public static Vector3D AlongX(Vector3D pos, PackingItem item) { 26 31 return new Vector3D( … … 86 91 return new Vector3D(a * b.X, a * b.Y, a * b.Z); 87 92 } 93 94 public static Vector3D operator *(double a, Vector3D b) { 95 return new Vector3D((int)(a * b.X), (int)(a * b.Y), (int)(a * b.Z)); 96 } 97 88 98 public static Vector3D operator *(Vector3D a, int b) { 89 99 return new Vector3D(a.X * b, a.Y * b, a.Z * b); 90 100 } 101 102 public static Vector3D operator *(Vector3D a, double b) { 103 return new Vector3D((int)(b * a.X), (int)(b * a.Y), (int)(b * a.Z)); 104 } 105 91 106 public static Vector3D operator +(Vector3D a, Vector3D b) { 92 107 return new Vector3D(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
Note: See TracChangeset
for help on using the changeset viewer.