本文整理汇总了C#中Sharp3D.Math.Core.Vector3D类的典型用法代码示例。如果您正苦于以下问题:C# Vector3D类的具体用法?C# Vector3D怎么用?C# Vector3D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Vector3D类属于Sharp3D.Math.Core命名空间,在下文中一共展示了Vector3D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestBoxInFront
public void TestBoxInFront()
{
Vector3D vCameraPos = new Vector3D(-10000.0, -10000.0, 10000.0);
Vector3D vTarget = new Vector3D(0.0, 0.0, 0.0);
Vector3D vDir = vTarget - vCameraPos;
Box b1 = new Box(1, 100.0, 100.0, 100.0);
b1.Position = new Vector3D(900.0, 900.0, 0.0);
Box b2 = new Box(2, 100.0, 100.0, 100.0);
b2.Position = new Vector3D(800.0, 900.0, 0.0);
Box b3 = new Box(3, 100.0, 100.0, 100.0);
b3.Position = new Vector3D(900.0, 800.0, 0.0);
Box b4 = new Box(3, 100.0, 100.0, 100.0);
b4.Position = new Vector3D(800.0, 800.0, 0.0);
Box b5 = new Box(3, 1000.0, 100.0, 100.0);
b5.Position = new Vector3D(0.0, 900.0, 0.0);
Box b6 = new Box(3, 100.0, 1000.0, 100.0);
b6.Position = new Vector3D(900.0, 0.0, 0.0);
Assert.False(b2.BoxInFront(b1, vDir));
Assert.False(b3.BoxInFront(b1, vDir));
Assert.False(b4.BoxInFront(b1, vDir));
Assert.False(b4.BoxInFront(b2, vDir));
Assert.False(b4.BoxInFront(b3, vDir));
Assert.False(b3.BoxInFront(b5, vDir));
Assert.False(b2.BoxInFront(b6, vDir));
}
示例2: TestIsPointInFront
public void TestIsPointInFront()
{
Face f = new Face(0, Vector3D.Zero, new Vector3D(100.0, 0.0, 0.0), new Vector3D(100.0, 0.0, 100.0), new Vector3D(0.0, 0.0, 100.0));
Vector3D viewDir = new Vector3D(1.0, 1.0, -1.0);
Assert.False(f.PointIsInFront(new Vector3D(50.0, 100.0, 50.0), viewDir));
Assert.True(f.PointIsInFront(new Vector3D(50.0, -100.0, 50.0), viewDir));
}
示例3: TestIsPointBehind
public void TestIsPointBehind()
{
Box b1 = new Box(1, 100.0, 100.0, 100.0);
Vector3D viewDir = new Vector3D(1.0, 1.0, -1.0);
Assert.True(b1.PointBehind(new Vector3D(50.0, 150.0, 50.0), viewDir));
Assert.False(b1.PointBehind(new Vector3D(50.0, -150.0, 50.0), viewDir));
}
示例4: Main
static void Main(string[] args)
{
bool bestLayersOnly = true;
Vector3D dimBox = new Vector3D(400.0, 300.0, 150.0);
Vector2D dimContainer = new Vector2D(1200.0, 1000.0);
ConstraintSetCasePallet constraintSet = new ConstraintSetCasePallet();
constraintSet.SetMaxHeight(1200.0);
try
{
LayerSolver solver = new LayerSolver();
List<Layer2D> layers = solver.BuildLayers(dimBox, dimContainer, constraintSet, bestLayersOnly);
int solIndex = 0;
foreach (Layer2D layer in layers)
{
string fileName = string.Format("{0}_{1}.bmp", layer.Name, solIndex++);
string filePath = Path.Combine(Path.GetTempPath(), fileName);
Console.WriteLine(string.Format("Generating {0}...", filePath));
Graphics2DImage graphics = new Graphics2DImage( new Size(150, 150) );
SolutionViewerLayer solViewer = new SolutionViewerLayer(layer);
BoxProperties bProperties = new BoxProperties(null, 400.0, 300.0, 150.0);
bProperties.SetColor(Color.Brown);
solViewer.Draw(graphics, bProperties, 1500.0);
graphics.SaveAs(filePath);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
示例5: AddPosition
public void AddPosition(LayerCyl layer, Vector2D vPosition)
{
Matrix4D matRot = Matrix4D.Identity;
Vector3D vTranslation = Vector3D.Zero;
if (_swapped)
{
matRot = new Matrix4D(
0.0, -1.0, 0.0, 0.0
, 1.0, 0.0, 0.0, 0.0
, 0.0, 0.0, 1.0, 0.0
, 0.0, 0.0, 0.0, 1.0
);
vTranslation = new Vector3D(layer.PalletLength, 0.0, 0.0);
}
Transform3D transfRot = new Transform3D(matRot);
matRot.M14 = vTranslation[0];
matRot.M24 = vTranslation[1];
matRot.M34 = vTranslation[2];
Transform3D transfRotTranslation = new Transform3D(matRot);
Vector3D vPositionSwapped = transfRotTranslation.transform(new Vector3D(vPosition.X, vPosition.Y, 0.0));
if (!layer.IsValidPosition(new Vector2D(vPositionSwapped.X, vPositionSwapped.Y)))
{
_log.Warn(string.Format("Attempt to add an invalid position in pattern = {0}, Swapped = true", this.Name));
return;
}
layer.Add(new Vector2D(vPositionSwapped.X, vPositionSwapped.Y));
}
示例6: TestCompareOrtho
public void TestCompareOrtho()
{
Vector3D vCameraPos = new Vector3D(-10000.0, -10000.0, 10000.0);
Vector3D vTarget = new Vector3D(0.0, 0.0, 0.0);
BoxComparer comparer = new BoxComparer(vCameraPos, vTarget);
Box b1 = new Box(1, 100.0, 100.0, 100.0);
b1.Position = new Vector3D(900.0, 900.0, 0.0);
Box b2 = new Box(2, 100.0, 100.0, 100.0);
b2.Position = new Vector3D(800.0, 900.0, 0.0);
Box b3 = new Box(3, 100.0, 100.0, 100.0);
b3.Position = new Vector3D(900.0, 800.0, 0.0);
Box b4 = new Box(4, 100.0, 100.0, 100.0);
b4.Position = new Vector3D(800.0, 800.0, 0.0);
Assert.AreEqual(0, comparer.Compare(b1, b1));
Assert.AreEqual(-1, comparer.Compare(b1, b2));
Assert.AreEqual(1, comparer.Compare(b2, b1));
Assert.AreEqual(-1, comparer.Compare(b1, b3));
Assert.AreEqual(1, comparer.Compare(b3, b1));
Assert.AreEqual(-1, comparer.Compare(b1, b4));
Assert.AreEqual(1, comparer.Compare(b4, b1));
Assert.AreEqual(-1, comparer.Compare(b2, b4));
Assert.AreEqual(1, comparer.Compare(b4, b2));
Assert.AreEqual(-1, comparer.Compare(b3, b4));
Assert.AreEqual(1, comparer.Compare(b4, b3));
}
示例7: BuildLayers
public List<Layer2D> BuildLayers(Vector3D dimBox, Vector2D dimContainer, ConstraintSetAbstract constraintSet, bool keepOnlyBest)
{
// instantiate list of layers
List<Layer2D> listLayers0 = new List<Layer2D>();
// loop through all patterns
foreach (LayerPattern pattern in LayerPattern.All)
{
// loop through all orientation
foreach (HalfAxis.HAxis axisOrtho in HalfAxis.All)
{
// is orientation allowed
if ( !constraintSet.AllowOrientation(axisOrtho) )
continue;
// not swapped vs swapped pattern
for (int iSwapped = 0; iSwapped < 1; ++iSwapped)
{
// does swapping makes sense for this layer pattern ?
if (!pattern.CanBeSwapped && (iSwapped == 1))
continue;
// instantiate layer
Layer2D layer = new Layer2D(dimBox, dimContainer, axisOrtho, iSwapped == 1);
layer.PatternName = pattern.Name;
double actualLength = 0.0, actualWidth = 0.0;
if (!pattern.GetLayerDimensionsChecked(layer, out actualLength, out actualWidth))
continue;
pattern.GenerateLayer(layer, actualLength, actualWidth);
if (0 == layer.Count)
continue;
listLayers0.Add(layer);
}
}
}
// keep only best layers
if (keepOnlyBest)
{
// 1. get best count
int bestCount = 0;
foreach (Layer2D layer in listLayers0)
bestCount = Math.Max(layer.CountInHeight(constraintSet.OptMaxHeight.Value), bestCount);
// 2. remove any layer that does not match the best count given its orientation
List<Layer2D> listLayers1 = new List<Layer2D>();
foreach (Layer2D layer in listLayers0)
{
if (layer.CountInHeight(constraintSet.OptMaxHeight.Value) >= bestCount)
listLayers1.Add(layer);
}
// 3. copy back in original list
listLayers0.Clear();
listLayers0.AddRange(listLayers1);
}
if (constraintSet.OptMaxHeight.Activated)
listLayers0.Sort(new LayerComparerCount(constraintSet.OptMaxHeight.Value));
return listLayers0;
}
示例8: PalletCap
public PalletCap(uint pickId, PalletCapProperties capProperties, Vector3D position)
{
_dim[0] = capProperties.Length;
_dim[1] = capProperties.Width;
_dim[2] = capProperties.Height;
_color = capProperties.Color;
Position = position;
}
示例9: TransformPosition
//����������ϵ�еĶ������ù����任���ֲ�����ϵ��
public Vector2D TransformPosition(Vector2D refPos)
{
//�����������ϵ�е�����
Vector2D relPos = GetRelPositon(refPos);
Vector3D homoPos = new Vector3D(relPos.X, relPos.Y, 1.0);
//�ӹ�������ϵ�任���ֲ�����ϵ
Vector3D TransformedPos = Matrix3D.Transform(m_totalMat, homoPos);
return new Vector2D(TransformedPos.X, TransformedPos.Y);
}
示例10: PalletData
private PalletData(string name, string description, Vector3D[] lumbers, Position[] positions, Vector3D dimensions, double weight, Color color)
{
_name = name;
_description = description;
_lumbers = new List<Vector3D>(lumbers);
_positions = new List<Position>(positions);
_defaultDimensions = dimensions;
_weight = weight;
_color = color;
}
示例11: Extend
public void Extend(Vector3D vec)
{
_ptMin.X = Math.Min(_ptMin.X, vec.X);
_ptMin.Y = Math.Min(_ptMin.Y, vec.Y);
_ptMin.Z = Math.Min(_ptMin.Z, vec.Z);
_ptMax.X = Math.Max(_ptMax.X, vec.X);
_ptMax.Y = Math.Max(_ptMax.Y, vec.Y);
_ptMax.Z = Math.Max(_ptMax.Z, vec.Z);
}
示例12: FilmRectangle
public FilmRectangle(
Vector3D origin,
HalfAxis.HAxis axis1, HalfAxis.HAxis axis2,
Vector2D dimensions,
double dBorder)
{
_origin = origin;
_axis1 = axis1;
_axis2 = axis2;
_dimensions = dimensions;
_dBorder = dBorder;
}
示例13: AddPosition
public void AddPosition(Layer layer, Vector2D vPosition, HalfAxis.HAxis lengthAxis, HalfAxis.HAxis widthAxis)
{
Matrix4D matRot = Matrix4D.Identity;
Vector3D vTranslation = Vector3D.Zero;
if (_swapped && !layer.Inversed)
{
matRot = new Matrix4D(
0.0, -1.0, 0.0, 0.0
, 1.0, 0.0, 0.0, 0.0
, 0.0, 0.0, 1.0, 0.0
, 0.0, 0.0, 0.0, 1.0
);
vTranslation = new Vector3D(layer.PalletLength, 0.0, 0.0);
}
else if (!_swapped && layer.Inversed)
{
matRot = new Matrix4D(
-1.0, 0.0, 0.0, 0.0
, 0.0, -1.0, 0.0, 0.0
, 0.0, 0.0, 1.0, 0.0
, 0.0, 0.0, 0.0, 1.0
);
vTranslation = new Vector3D(layer.PalletLength, layer.PalletWidth, 0.0);
}
else if (_swapped && layer.Inversed)
{
matRot = new Matrix4D(
0.0, 1.0, 0.0, 0.0
, -1.0, 0.0, 0.0, 0.0
, 0.0, 0.0, 1.0, 0.0
, 0.0, 0.0, 0.0, 1.0
);
vTranslation = new Vector3D(0.0, layer.PalletWidth, 0.0);
}
Transform3D transfRot = new Transform3D(matRot);
HalfAxis.HAxis lengthAxisSwapped = StackBuilder.Basics.HalfAxis.ToHalfAxis(transfRot.transform(StackBuilder.Basics.HalfAxis.ToVector3D(lengthAxis)));
HalfAxis.HAxis widthAxisSwapped = StackBuilder.Basics.HalfAxis.ToHalfAxis(transfRot.transform(StackBuilder.Basics.HalfAxis.ToVector3D(widthAxis)));
matRot.M14 = vTranslation[0];
matRot.M24 = vTranslation[1];
matRot.M34 = vTranslation[2];
Transform3D transfRotTranslation = new Transform3D(matRot);
Vector3D vPositionSwapped = transfRotTranslation.transform(new Vector3D(vPosition.X, vPosition.Y, 0.0));
if (!layer.IsValidPosition(new Vector2D(vPositionSwapped.X, vPositionSwapped.Y), lengthAxisSwapped, widthAxisSwapped))
{
_log.Warn(string.Format("Attempt to add an invalid position in pattern = {0}, Variant = {1}, Swapped = true", this.Name, _variantIndex));
return;
}
layer.AddPosition(new Vector2D(vPositionSwapped.X, vPositionSwapped.Y), lengthAxisSwapped, widthAxisSwapped);
}
示例14: BuildLayer
public Layer2D BuildLayer(Vector3D dimBox, Vector2D dimContainer, LayerDesc layerDesc)
{
// instantiate layer
Layer2D layer = new Layer2D(dimBox, dimContainer, layerDesc.AxisOrtho, false);
// get layer pattern
LayerPattern pattern = LayerPattern.GetByName(layerDesc.PatternName);
// dimensions
double actualLength = 0.0, actualWidth = 0.0;
if (!pattern.GetLayerDimensionsChecked(layer, out actualLength, out actualWidth))
return null;
pattern.GenerateLayer(layer, actualLength, actualWidth);
return layer;
}
示例15: CaseOptimConstraintSet
public CaseOptimConstraintSet(
int[] noWalls
, double wallThickness, double wallSurfaceMass
, Vector3D caseLimitMin, Vector3D caseLimitMax
, bool forceVerticalCaseOrientation)
{
NoWalls = noWalls;
_wallThickness = wallThickness;
_wallSurfaceMass = wallSurfaceMass;
_caseLimitMin = caseLimitMin;
_caseLimitMax = caseLimitMax;
_forceVerticalCaseOrientation = forceVerticalCaseOrientation;
}