本文整理匯總了C#中Sharp3D.Math.Core.Vector2D類的典型用法代碼示例。如果您正苦於以下問題:C# Vector2D類的具體用法?C# Vector2D怎麽用?C# Vector2D使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Vector2D類屬於Sharp3D.Math.Core命名空間,在下文中一共展示了Vector2D類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Bone
public Bone(string name)
{
m_refPosition = new Vector2D(0.0, 0.0);
m_mat = Matrix3D.Identity.Clone();
m_totalMat = Matrix3D.Identity.Clone();
m_name = name;
}
示例2: PointToAboveSegment
public static bool PointToAboveSegment(Vector2D p, Segment seg, ref double distance)
{
double xMin = System.Math.Min(seg.P0.X, seg.P1.X);
double xMax = System.Math.Max(seg.P0.X, seg.P1.X);
if (p.X < xMin - MathFunctions.EpsilonF || p.X > xMax + MathFunctions.EpsilonF)
return false;
else
{
double yMin = System.Math.Min(seg.P0.Y, seg.P1.Y);
double yMax = System.Math.Max(seg.P0.Y, seg.P1.Y);
if (System.Math.Abs(seg.P1.X - seg.P0.X) < MathFunctions.EpsilonF)
{
if (p.Y < yMin)
distance = yMin - p.Y;
else if (p.Y > yMax)
distance = yMax - p.Y;
else
distance = 0.0f;
}
else
distance = seg.P0.Y + (p.X - seg.P0.X) * (seg.P1.Y - seg.P0.Y) / (seg.P1.X - seg.P0.X) - p.Y;
return true;
}
}
示例3: DrawLine
public void DrawLine(Vector2D v1, Vector2D v2, Color penColor)
{
Point[] pt = TransformPoint(new Vector2D[] { v1, v2 });
System.Drawing.Graphics g = Graphics;
Pen pen = new Pen(penColor);
g.DrawLines(pen, pt);
}
示例4: CreateNewSegment
public static PicSegment CreateNewSegment(uint id, PicGraphics.LT lType, Vector2D pt0, Vector2D pt1)
{
PicSegment segment = new PicSegment(id, lType);
segment._pt0 = pt0;
segment._pt1 = pt1;
return segment;
}
示例5: PicCotationDistance
protected PicCotationDistance(uint id, Vector2D pt0, Vector2D pt1, double offset, short noDecimals)
: base(id, noDecimals)
{
_pt0 = pt0;
_pt1 = pt1;
_offset = offset;
}
示例6: DrawRectangle
public void DrawRectangle(Vector2D vMin, Vector2D vMax, Color penColor)
{
Point[] pt = TransformPoint(new Vector2D[] { vMin, vMax });
System.Drawing.Graphics g = Graphics;
Pen penRect = new Pen(penColor);
g.DrawRectangle(penRect, pt[0].X, pt[0].Y, pt[1].X-pt[0].X, pt[1].Y-pt[0].Y);
}
示例7: Arc
/// <summary>
/// Initializes a new instance of the <see cref="Arc"/> class.
/// </summary>
/// <param name="pCenter">A <see cref="Vector2D"/> instance marking the <see cref="Arc"/>'s center point.</param>
/// <param name="radius">The <see cref="Arc"/>'s radius.</param>
/// <param name="angle0">The <see cref="Arc"/>'s starting angle.</param>
/// <param name="angle1">The <see cref="Arc"/>'s ending angle.</param>
public Arc(Vector2D pCenter, float radius, float angle0, float angle1)
{
_pCenter = pCenter;
_radius = radius;
_angle0 = angle0;
_angle1 = angle1;
}
示例8: 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));
}
示例9: 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);
}
}
示例10: IsMiddleQuotation
protected virtual bool IsMiddleQuotation(Vector2D pt2, Vector2D pt3, double textWidth, double textHeight)
{
double length = (pt3 - pt2).GetLength();
if (Math.Abs(pt3.Y - pt2.Y) < (textHeight / textWidth) * Math.Abs(pt3.X - pt2.X))
return Math.Abs((pt3 - pt2).X) > textWidth * _globalCotationProperties._lengthCoef;
else
return Math.Abs((pt3 - pt2).Y) > textHeight * _globalCotationProperties._lengthCoef;
}
示例11: 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;
}
示例12: CreateNewArc
public static PicArc CreateNewArc(uint id, PicGraphics.LT lType, Vector2D center, double radius, double angleBeg, double angleEnd)
{
PicArc arc = new PicArc(id, lType);
arc._center = center;
arc._radius = radius;
arc._angleBeg = angleBeg;
arc._angleEnd = angleEnd;
return arc;
}
示例13: DrawLine
public override void DrawLine(LT lineType, Vector2D ptBeg, Vector2D ptEnd)
{
_cb.SetLineWidth(0.0f);
_cb.SetColorStroke(LineTypeToBaseColor(lineType));
_cb.MoveTo(DX(ptBeg.X), DY(ptBeg.Y));
_cb.LineTo(DX(ptEnd.X), DY(ptEnd.Y));
_cb.Stroke();
}
示例14: 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);
}
示例15: GetOffsetPoints
protected virtual void GetOffsetPoints(out Vector2D pt2, out Vector2D pt3)
{
// build normal
Vector2D vI = (_pt1 - _pt0); vI.Normalize();
Vector2D vJ = new Vector2D(vI.Y, -vI.X);
double delta = -_globalCotationProperties._hrap;
pt2 = new Vector2D(_pt0 + vJ * _offset + Math.Sign(_offset) * delta * vJ);
pt3 = new Vector2D(_pt1 + vJ * _offset + Math.Sign(_offset) * delta * vJ);
}