Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/28/17 16:10:31 (7 years ago)
Author:
rhanghof
Message:

#2817:

  • Added line projection based bin packing
  • Added residual spaces to the view
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  
    2929      return plane.Intersect(this);
    3030    }
     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    }
    3162  }
    3263}
  • branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Geometry/Vector3D.cs

    r15454 r15488  
    66
    77namespace HeuristicLab.Problems.BinPacking3D.Geometry {
    8   internal class Vector3D {
     8  public class Vector3D {
    99
    1010    public int X { get; set; }
     
    2323      Z = pos.Z;
    2424    }
     25
     26    public PackingPosition ToPackingPosition(int assignedBin) {
     27      return new PackingPosition(assignedBin, X, Y, Z);
     28    }
     29
    2530    public static Vector3D AlongX(Vector3D pos, PackingItem item) {
    2631      return new Vector3D(
     
    8691      return new Vector3D(a * b.X, a * b.Y, a * b.Z);
    8792    }
     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
    8898    public static Vector3D operator *(Vector3D a, int b) {
    8999      return new Vector3D(a.X * b, a.Y * b, a.Z * b);
    90100    }
     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
    91106    public static Vector3D operator +(Vector3D a, Vector3D b) {
    92107      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.