public void AddPosition(Vector2D vPosition, HalfAxis.HAxis lengthAxis, HalfAxis.HAxis widthAxis) { // build 4D matrix Vector3D vAxisLength = HalfAxis.ToVector3D(lengthAxis); Vector3D vAxisWidth = HalfAxis.ToVector3D(widthAxis); Vector3D vAxisHeight = Vector3D.CrossProduct(vAxisLength, vAxisWidth); Matrix4D mat = Matrix4D.Identity; mat.M11 = vAxisLength.X; mat.M12 = vAxisLength.Y; mat.M13 = vAxisLength.Z; mat.M21 = vAxisWidth.X; mat.M22 = vAxisWidth.Y; mat.M23 = vAxisWidth.Z; mat.M31 = vAxisHeight.X; mat.M32 = vAxisHeight.Y; mat.M33 = vAxisHeight.Z; mat.M41 = 0.0; mat.M42 = 0.0; mat.M43 = 0.0; mat.M44 = 1.0; Transform3D localTransf = new Transform3D(mat); Transform3D localTransfInv = localTransf.Inverse(); Transform3D originTranslation = Transform3D.Translation(localTransfInv.transform(VecTransf) - new Vector3D(0.5 * ForcedSpace, 0.5 * ForcedSpace, 0.0)); var layerPos = new BoxPosition( originTranslation.transform(new Vector3D(vPosition.X, vPosition.Y, 0.0) + 0.5 * ForcedSpace * vAxisLength + 0.5 * ForcedSpace * vAxisWidth) , HalfAxis.ToHalfAxis(localTransfInv.transform(HalfAxis.ToVector3D(LengthAxis))) , HalfAxis.ToHalfAxis(localTransfInv.transform(HalfAxis.ToVector3D(WidthAxis))) ); layerPos.Position += new Vector3D(0.5 * ForcedSpace, 0.5 * ForcedSpace, 0.0); // add position Add(layerPos.Adjusted(DimBox)); }
public CylPosition Transform(Transform3D transf) { return(new CylPosition( transf.transform(_vPosition), HalfAxis.ToHalfAxis(transf.transformRot(HalfAxis.ToVector3D(_axis))) )); }
public BoxPosition Translate(HalfAxis.HAxis axis, double value) { Vector3D v = Position; v += value * HalfAxis.ToVector3D(axis); return(new BoxPosition(v, DirectionLength, DirectionWidth)); }
public BoxPosition ToBoxPosition(BBox3D bbox) { Vector3D vOrig = Vector3D.Zero; HalfAxis.HAxis axis = HalfAxis.HAxis.AXIS_Y_P; switch (Side) { case HalfAxis.HAxis.AXIS_X_N: vOrig = new Vector3D(bbox.PtMin.X, bbox.PtMax.Y, bbox.PtMin.Z); axis = HalfAxis.HAxis.AXIS_Y_N; break; case HalfAxis.HAxis.AXIS_Y_N: vOrig = new Vector3D(bbox.PtMin.X, bbox.PtMin.Y, bbox.PtMin.Z); axis = HalfAxis.HAxis.AXIS_X_P; break; case HalfAxis.HAxis.AXIS_X_P: vOrig = new Vector3D(bbox.PtMax.X, bbox.PtMin.Y, bbox.PtMin.Z); axis = HalfAxis.HAxis.AXIS_Y_P; break; case HalfAxis.HAxis.AXIS_Y_P: vOrig = new Vector3D(bbox.PtMax.X, bbox.PtMax.Y, bbox.PtMin.Z); axis = HalfAxis.HAxis.AXIS_X_N; break; default: break; } return(new BoxPosition(vOrig + Position.X * HalfAxis.ToVector3D(axis) + Position.Y * Vector3D.ZAxis, axis, HalfAxis.HAxis.AXIS_Z_P)); }
public BBox3D BoundingBox(Packable packable) { BBox3D bbox = new BBox3D(); if (packable is PackableBrick packableBrick) { Vector3D dimensions = packableBrick.OuterDimensions; foreach (BoxPosition bpos in this) { Vector3D[] pts = new Vector3D[8]; Vector3D vI = HalfAxis.ToVector3D(bpos.DirectionLength); Vector3D vJ = HalfAxis.ToVector3D(bpos.DirectionWidth); Vector3D vK = Vector3D.CrossProduct(vI, vJ); pts[0] = bpos.Position; pts[1] = bpos.Position + dimensions.X * vI; pts[2] = bpos.Position + dimensions.Y * vJ; pts[3] = bpos.Position + dimensions.X * vI + dimensions.Y * vJ; pts[4] = bpos.Position + dimensions.Z * vK; pts[5] = bpos.Position + dimensions.Y * vJ + dimensions.Z * vK; pts[6] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionWidth) * dimensions.Y; pts[7] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionLength) * dimensions.X + HalfAxis.ToVector3D(bpos.DirectionWidth) * dimensions.Y; foreach (Vector3D pt in pts) { bbox.Extend(pt); } } } return(bbox); }
public BoxPosition RotateZ180(Vector3D dim) { Vector3D v = Position; v += dim.X * HalfAxis.ToVector3D(DirectionLength) + dim.Y * HalfAxis.ToVector3D(DirectionWidth); return(new BoxPosition(v, HalfAxis.Opposite(DirectionLength), HalfAxis.Opposite(DirectionWidth))); }
public BBox3D BoundingBox(PackProperties packProperties) { BBox3D bbox = new BBox3D(); foreach (BoxPosition bpos in this) { Vector3D[] pts = new Vector3D[8]; Vector3D vI = HalfAxis.ToVector3D(bpos.DirectionLength); Vector3D vJ = HalfAxis.ToVector3D(bpos.DirectionWidth); Vector3D vK = Vector3D.CrossProduct(vI, vJ); pts[0] = bpos.Position; pts[1] = bpos.Position + packProperties.Length * vI; pts[2] = bpos.Position + packProperties.Width * vJ; pts[3] = bpos.Position + packProperties.Length * vI + packProperties.Width * vJ; pts[4] = bpos.Position + packProperties.Height * vK; pts[5] = bpos.Position + packProperties.Width * vJ + packProperties.Height * vK;; pts[6] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionWidth) * packProperties.Width; pts[7] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionLength) * packProperties.Length + HalfAxis.ToVector3D(bpos.DirectionWidth) * packProperties.Width; foreach (Vector3D pt in pts) { bbox.Extend(pt); } } return(bbox); }
public Vector3D Center(Vector3D dimensions) { Vector3D vI = HalfAxis.ToVector3D(DirectionLength); Vector3D vJ = HalfAxis.ToVector3D(DirectionWidth); Vector3D vK = Vector3D.CrossProduct(vI, vJ); return(Position + (0.5 * dimensions.X * vI) + (0.5 * dimensions.Y * vJ) + (0.5 * dimensions.Z * vK)); }
public Layer3DBoxIndexed Sort(Packable packable) { Vector3D dimensions = packable.OuterDimensions; Vector3D minPoint = BoundingBox(packable).PtMin; Dictionary <int, double> dictIndexDist = new Dictionary <int, double>(); foreach (var boxPos in this) { int index = boxPos.Index; double maxDist = boxPos.BPos.MaxDistance(dimensions, minPoint); if (dictIndexDist.ContainsKey(index)) { dictIndexDist[index] = Math.Max(dictIndexDist[index], maxDist); } else { dictIndexDist.Add(index, maxDist); } } // sort by ascending distance var sortedDict = from entry in dictIndexDist orderby entry.Value ascending select entry; // instantiate new layer Layer3DBoxIndexed sortedLayer = new Layer3DBoxIndexed(ZLow, LayerIndex); foreach (var elt in sortedDict) { int index = elt.Key; var boxPositions = FindAll(bp => bp.Index == index); Vector3D vAxisWidth = HalfAxis.ToVector3D(boxPositions[0].BPos.DirectionWidth); boxPositions.Sort( delegate(BoxPositionIndexed bp1, BoxPositionIndexed bp2) { double abscissa1 = Vector3D.DotProduct(bp1.BPos.Position, vAxisWidth); double abscissa2 = Vector3D.DotProduct(bp2.BPos.Position, vAxisWidth); if (abscissa1 > abscissa2) { return(1); } else if (abscissa2 < abscissa1) { return(-1); } else { return(0); } }); foreach (var bpos in boxPositions) { sortedLayer.Add(bpos); } } return(sortedLayer); }
public static CylPosition Transform(CylPosition cylPosition, Transform3D transform) { return(new CylPosition( transform.transform(cylPosition.XYZ), HalfAxis.ToHalfAxis( transform.transformRot(HalfAxis.ToVector3D(cylPosition.Direction)) ) )); }
public void AddPosition(Vector2D vPosition, HalfAxis.HAxis lengthAxis, HalfAxis.HAxis widthAxis) { // build 4D matrix Vector3D vAxisLength = HalfAxis.ToVector3D(lengthAxis); Vector3D vAxisWidth = HalfAxis.ToVector3D(widthAxis); Vector3D vAxisHeight = Vector3D.CrossProduct(vAxisLength, vAxisWidth); Matrix4D mat = Matrix4D.Identity; mat.M11 = vAxisLength.X; mat.M12 = vAxisLength.Y; mat.M13 = vAxisLength.Z; mat.M21 = vAxisWidth.X; mat.M22 = vAxisWidth.Y; mat.M23 = vAxisWidth.Z; mat.M31 = vAxisHeight.X; mat.M32 = vAxisHeight.Y; mat.M33 = vAxisHeight.Z; mat.M41 = 0.0; mat.M42 = 0.0; mat.M43 = 0.0; mat.M44 = 1.0; Transform3D localTransf = new Transform3D(mat); Transform3D localTransfInv = localTransf.Inverse(); Transform3D originTranslation = Transform3D.Translation(localTransfInv.transform(VecTransf) - new Vector3D(0.5 * ForcedSpace, 0.5 * ForcedSpace, 0.0)); var layerPos = new BoxPosition( originTranslation.transform(new Vector3D(vPosition.X, vPosition.Y, 0.0) + 0.5 * ForcedSpace * vAxisLength + 0.5 * ForcedSpace * vAxisWidth) , HalfAxis.ToHalfAxis(localTransfInv.transform(HalfAxis.ToVector3D(LengthAxis))) , HalfAxis.ToHalfAxis(localTransfInv.transform(HalfAxis.ToVector3D(WidthAxis))) ); // spacing ? layerPos.Position += new Vector3D(0.5 * ForcedSpace, 0.5 * ForcedSpace, 0.0); var bposAdj = layerPos.Adjusted(DimBoxTotal); // bulge ? Vector3D vecBulge = Vector3D.Zero; if (Bulge.X > 0) { vecBulge += 0.5 * Bulge.X * HalfAxis.ToVector3D(bposAdj.DirectionLength); } if (Bulge.Y > 0) { vecBulge += 0.5 * Bulge.Y * HalfAxis.ToVector3D(bposAdj.DirectionWidth); } if (Bulge.Z > 0) { vecBulge += 0.5 * Bulge.Z * HalfAxis.ToVector3D(bposAdj.DirectionHeight); } bposAdj.Position += vecBulge; // add position Add(bposAdj); }
/* * /// <summary> * /// Compute layer bouding box * /// </summary> * /// <param name="bProperties">Case properties</param> * /// <returns>bounding box</returns> * public BBox3D BoundingBox(BProperties bProperties) * { * BBox3D bbox = new BBox3D(); * * foreach (BoxPosition bpos in this) * { * Vector3D[] pts = new Vector3D[8]; * Vector3D vI = HalfAxis.ToVector3D(bpos.DirectionLength); * Vector3D vJ = HalfAxis.ToVector3D(bpos.DirectionWidth); * Vector3D vK = Vector3D.CrossProduct(vI, vJ); * pts[0] = bpos.Position; * pts[1] = bpos.Position + bProperties.Length * vI; * pts[2] = bpos.Position + bProperties.Width * vJ; * pts[3] = bpos.Position + bProperties.Length * vI + bProperties.Width * vJ; * pts[4] = bpos.Position + bProperties.Height * vK; * pts[5] = bpos.Position + bProperties.Width * vJ + bProperties.Height * vK; ; * pts[6] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionWidth) * bProperties.Width; * pts[7] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionLength) * bProperties.Length + HalfAxis.ToVector3D(bpos.DirectionWidth) * bProperties.Width; * * foreach (Vector3D pt in pts) * bbox.Extend(pt); * } * return bbox; * } * * public BBox3D BoundingBox(PackProperties packProperties) * { * BBox3D bbox = new BBox3D(); * * foreach (BoxPosition bpos in this) * { * Vector3D[] pts = new Vector3D[8]; * Vector3D vI = HalfAxis.ToVector3D(bpos.DirectionLength); * Vector3D vJ = HalfAxis.ToVector3D(bpos.DirectionWidth); * Vector3D vK = Vector3D.CrossProduct(vI, vJ); * pts[0] = bpos.Position; * pts[1] = bpos.Position + packProperties.Length * vI; * pts[2] = bpos.Position + packProperties.Width * vJ; * pts[3] = bpos.Position + packProperties.Length * vI + packProperties.Width * vJ; * pts[4] = bpos.Position + packProperties.Height * vK; * pts[5] = bpos.Position + packProperties.Width * vJ + packProperties.Height * vK; ; * pts[6] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionWidth) * packProperties.Width; * pts[7] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionLength) * packProperties.Length + HalfAxis.ToVector3D(bpos.DirectionWidth) * packProperties.Width; * * foreach (Vector3D pt in pts) * bbox.Extend(pt); * } * * return bbox; * } */ public double Thickness(BProperties bProperties) { if (Count == 0) { return(0.0); } BoxPosition bPos = this[0]; Vector3D diagonale = bProperties.Length * HalfAxis.ToVector3D(bPos.DirectionLength) + bProperties.Width * HalfAxis.ToVector3D(bPos.DirectionWidth) + bProperties.Height * Vector3D.CrossProduct(HalfAxis.ToVector3D(bPos.DirectionLength), HalfAxis.ToVector3D(bPos.DirectionWidth)); return(Math.Abs(diagonale.Z)); }
public bool IntersectWithContent(CylPosition cylPosition) { Vector3D cylDirection = HalfAxis.ToVector3D(cylPosition.Direction); foreach (CylPosition c in Positions) { Vector3D vDiff = c.XYZ - cylPosition.XYZ; double axisProj = Vector3D.DotProduct(cylDirection, vDiff); Vector3D vDiffProj = vDiff - axisProj * cylDirection; if (axisProj < CylLength && vDiffProj.GetLength() < CylRadius) { return(true); } } return(false); }
public void MinMax(double boxLength, double boxWidth, out Vector2D vMin, out Vector2D vMax) { Vector3D[] pts = new Vector3D[4]; pts[0] = new Vector3D(_position.X, _position.Y, 0.0); pts[1] = new Vector3D(_position.X, _position.Y, 0.0) + HalfAxis.ToVector3D(_lengthAxis) * boxLength; pts[2] = new Vector3D(_position.X, _position.Y, 0.0) + HalfAxis.ToVector3D(_widthAxis) * boxWidth; pts[3] = new Vector3D(_position.X, _position.Y, 0.0) + HalfAxis.ToVector3D(_lengthAxis) * boxLength + HalfAxis.ToVector3D(_widthAxis) * boxWidth; vMin = new Vector2D(double.MaxValue, double.MaxValue); vMax = new Vector2D(double.MinValue, double.MinValue); foreach (Vector3D v in pts) { vMin.X = Math.Min(v.X, vMin.X); vMin.Y = Math.Min(v.Y, vMin.Y); vMax.X = Math.Max(v.X, vMax.X); vMax.Y = Math.Max(v.Y, vMax.Y); } }
private BBox3D ComputeLoadBBox3D() { double palletLength = ParentTruckAnalysis.ParentSolution.PalletLength; double palletWidth = ParentTruckAnalysis.ParentSolution.PalletWidth; double palletHeight = ParentTruckAnalysis.ParentSolution.PalletHeight; BBox3D bbox = new BBox3D(); int iLayer = 0; while (iLayer < NoLayers) { foreach (BoxPosition bPositionLayer in Layer) { // actual position in load BoxPosition bpos = new BoxPosition( new Vector3D( bPositionLayer.Position.X , bPositionLayer.Position.Y , bPositionLayer.Position.Z + palletHeight * iLayer) , bPositionLayer.DirectionLength , bPositionLayer.DirectionWidth); Vector3D[] pts = new Vector3D[8]; Vector3D vI = HalfAxis.ToVector3D(bpos.DirectionLength); Vector3D vJ = HalfAxis.ToVector3D(bpos.DirectionWidth); Vector3D vK = Vector3D.CrossProduct(vI, vJ); pts[0] = bpos.Position; pts[1] = bpos.Position + palletLength * vI; pts[2] = bpos.Position + palletWidth * vJ; pts[3] = bpos.Position + palletLength * vI + palletWidth * vJ; pts[4] = bpos.Position + palletHeight * vK; pts[5] = bpos.Position + palletWidth * vJ + palletHeight * vK;; pts[6] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionWidth) * palletWidth; pts[7] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionLength) * palletLength + HalfAxis.ToVector3D(bpos.DirectionWidth) * palletWidth; foreach (Vector3D pt in pts) { bbox.Extend(pt); } } ++iLayer; } return(bbox); }
public bool IsValidPosition(Vector2D vPosition, HalfAxis.HAxis lengthAxis, HalfAxis.HAxis widthAxis) { // check layerPos // get 4 points Vector3D[] pts = new Vector3D[4]; pts[0] = new Vector3D(vPosition.X, vPosition.Y, 0.0); pts[1] = new Vector3D(vPosition.X, vPosition.Y, 0.0) + HalfAxis.ToVector3D(lengthAxis) * BoxLength; pts[2] = new Vector3D(vPosition.X, vPosition.Y, 0.0) + HalfAxis.ToVector3D(widthAxis) * BoxWidth; pts[3] = new Vector3D(vPosition.X, vPosition.Y, 0.0) + HalfAxis.ToVector3D(lengthAxis) * BoxLength + HalfAxis.ToVector3D(widthAxis) * BoxWidth; foreach (Vector3D pt in pts) { if (pt.X < (0.0 - _epsilon) || pt.X > (DimContainer.X + _epsilon) || pt.Y < (0.0 - _epsilon) || pt.Y > (DimContainer.Y + _epsilon)) { return(false); } } return(true); }
private LayerPosition ApplyReflection(LayerPosition layerPos, Matrix4D matRot, Vector3D vTranslation) { Vector3D dimensions = Analysis.ContentDimensions; Transform3D transfRot = new Transform3D(matRot); HalfAxis.HAxis axisLength = HalfAxis.ToHalfAxis(transfRot.transform(HalfAxis.ToVector3D(layerPos.LengthAxis))); HalfAxis.HAxis axisWidth = HalfAxis.ToHalfAxis(transfRot.transform(HalfAxis.ToVector3D(layerPos.WidthAxis))); matRot.M14 = vTranslation[0]; matRot.M24 = vTranslation[1]; matRot.M34 = vTranslation[2]; Transform3D transfRotTranslation = new Transform3D(matRot); Vector3D transPos = transfRotTranslation.transform(new Vector3D(layerPos.Position.X, layerPos.Position.Y, layerPos.Position.Z)); return(new LayerPosition( new Vector3D(transPos.X, transPos.Y, transPos.Z) - dimensions.Z * Vector3D.CrossProduct(HalfAxis.ToVector3D(axisLength), HalfAxis.ToVector3D(axisWidth)) , axisLength , axisWidth)); }
private Vector3D[] Points(Vector3D dim) { Vector3D position = Position; Vector3D vI = HalfAxis.ToVector3D(DirectionLength); Vector3D vJ = HalfAxis.ToVector3D(DirectionWidth); Vector3D vK = Vector3D.CrossProduct(vI, vJ); var points = new Vector3D[8]; points[0] = position; points[1] = position + dim[0] * vI; points[2] = position + dim[0] * vI + dim[1] * vJ; points[3] = position + dim[1] * vJ; points[4] = position + dim[2] * vK; points[5] = position + dim[2] * vK + dim[0] * vI; points[6] = position + dim[2] * vK + dim[0] * vI + dim[1] * vJ; points[7] = position + dim[2] * vK + dim[1] * vJ; return(points); }
public BBox3D BBox(Vector3D dimensions) { BBox3D bbox = new BBox3D(); Vector3D vI = HalfAxis.ToVector3D(DirectionLength); Vector3D vJ = HalfAxis.ToVector3D(DirectionWidth); Vector3D vK = Vector3D.CrossProduct(vI, vJ); Vector3D[] pts = new Vector3D[8]; pts[0] = Position; pts[1] = Position + dimensions.X * vI; pts[2] = Position + dimensions.Y * vJ; pts[3] = Position + dimensions.X * vI + dimensions.Y * vJ; pts[4] = Position + dimensions.Z * vK; pts[5] = Position + dimensions.Y * vJ + dimensions.Z * vK; pts[6] = Position + HalfAxis.ToVector3D(DirectionWidth) * dimensions.Y; pts[7] = Position + HalfAxis.ToVector3D(DirectionLength) * dimensions.X + HalfAxis.ToVector3D(DirectionWidth) * dimensions.Y; foreach (Vector3D pt in pts) { bbox.Extend(pt); } return(bbox); }
public BBox3D(BoxPosition bPos, Vector3D dim) { Vector3D lengthAxis = HalfAxis.ToVector3D(bPos.DirectionLength); Vector3D widthAxis = HalfAxis.ToVector3D(bPos.DirectionWidth); Vector3D heightAxis = HalfAxis.ToVector3D(bPos.DirectionHeight); var points = new Vector3D[8]; points[0] = bPos.Position; points[1] = bPos.Position + dim[0] * lengthAxis; points[2] = bPos.Position + dim[0] * lengthAxis + dim[1] * widthAxis; points[3] = bPos.Position + dim[1] * widthAxis; points[4] = bPos.Position + dim[2] * heightAxis; points[5] = bPos.Position + dim[2] * heightAxis + dim[0] * lengthAxis; points[6] = bPos.Position + dim[2] * heightAxis + dim[0] * lengthAxis + dim[1] * widthAxis; points[7] = bPos.Position + dim[2] * heightAxis + dim[1] * widthAxis; foreach (var pt in points) { Extend(pt); } }
public static HAxis ReflectionX(HAxis axis) { Vector3D v = HalfAxis.ToVector3D(axis); return(HalfAxis.ToHalfAxis(new Vector3D(v.X, -v.Y, v.Z))); }
public static HAxis Transform(HAxis axis, Transform3D transform) { return(ToHalfAxis(transform.transformRot(HalfAxis.ToVector3D(axis)))); }