本文整理汇总了C#中Point2D类的典型用法代码示例。如果您正苦于以下问题:C# Point2D类的具体用法?C# Point2D怎么用?C# Point2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Point2D类属于命名空间,在下文中一共展示了Point2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawLine
public static Line2D DrawLine(this Factory2D F, Point2D Start, Point2D End)
{
Line2D L = F.CreateLine(Start.GetPos(), End.GetPos());
L.StartPoint = Start;
L.EndPoint = End;
return L;
}
示例2: Distance
/// <summary>
/// Finds the distance of a specified point from the line segment and the
/// closest point on the segment to the specified point.
/// </summary>
/// <param name="p">The test point.</param>
/// <param name="closestPt">Closest point on the segment to c.</param>
/// <returns>Returns the distance from p to the closest point on the segment.</returns>
public double Distance(Point2D p, Point2D closestPt)
{
if (closestPt == null)
closestPt = new Point2D();
// Construct vector v (AB) and w (AP)
var v = new Vector2D(A, B);
var w = new Vector2D(A, p);
// Numerator of the component of w onto v. If <= 0 then A
// is the closest point. By separating into the numerator
// and denominator of the component we avoid a division unless
// it is necessary.
double n = w.Dot(v);
if (n <= 0.0f)
{
closestPt.Set(A);
return w.Norm();
}
// Get the denominator of the component. If the component >= 1
// (d <= n) then point B is the closest point
double d = v.Dot(v);
if (d <= n)
{
closestPt.Set(B);
return new Vector2D(B, p).Norm();
}
// Closest point is along the segment. The point is the projection of
// w onto v.
closestPt.Set(v.Mult(n / d));
closestPt.Add(A);
return new Vector2D(closestPt, p).Norm();
}
示例3: Point2D_IsConstructedProperly
public void Point2D_IsConstructedProperly()
{
var result = new Point2D(123.45, 456.78);
TheResultingValue(result)
.ShouldBe(123.45, 456.78);
}
示例4: DrawLine
public static void DrawLine(Point2D tFrom, Point2D tTo, Texture2D texture)
{
//Debug.Log ("Drawing from: " + tFrom.x + "," + tFrom.y + " to " + tTo.x + "," + tTo.y);
int deltaX = tFrom.x - tTo.x;
int deltaY = tFrom.y - tTo.y;
int d = 2*deltaY - deltaX;
texture.SetPixel(tFrom.x,tFrom.y,Color.black);
int y = tFrom.y;
for(int x = tFrom.x + 1; x< tTo.x; x+=1)
{
if(d > 0)
{
y+=1;
//Debug.Log (x + " " + y);
texture.SetPixel(x,y,Color.black);
d+=(2*deltaY)-(2*deltaX);
}
else
{
//Debug.Log (x + " " + y);
texture.SetPixel(x,y,Color.black);
d+=(2*deltaY);
}
}
texture.Apply();
}
示例5: MahjongDealerIndicator
public MahjongDealerIndicator(MahjongGame game, Point2D position, MahjongPieceDirection direction, MahjongWind wind)
{
this.m_Game = game;
this.m_Position = position;
this.m_Direction = direction;
this.m_Wind = wind;
}
示例6: ExpandableScroll
public ExpandableScroll(Control owner, int page, int x, int y, int height)
: base(0, 0)
{
_owner = owner;
Position = new Point2D(x, y);
_expandableScrollHeight = height;
}
示例7: getGazeCoordsToUnityWindowCoords
/// <summary>
/// Maps a GazeData gaze point (RawCoordinates or SmoothedCoordinates) to Unity screen space.
/// Note that gaze points have origo in top left corner, whilst Unity uses lower left.
/// </summary>
/// <param name="gp"/>gaze point to map</param>
/// <returns>2d point mapped to unity window space</returns>
public static Point2D getGazeCoordsToUnityWindowCoords(Point2D gp)
{
double rx = gp.X * ((double)Screen.width / GazeManager.Instance.ScreenResolutionWidth);
double ry = (GazeManager.Instance.ScreenResolutionHeight - gp.Y) * ((double)Screen.height / GazeManager.Instance.ScreenResolutionHeight);
return new Point2D(rx, ry);
}
示例8: IsPotentialHit
/// <summary>
/// Gets a value indicating whether the specified point is potentially a hit for the specified element.
/// </summary>
/// <param name="element">The element to evaluate.</param>
/// <param name="point">The point to evaluate.</param>
/// <returns><see langword="true"/> if the specified point is a potential hit; otherwise, <see langword="false"/>.</returns>
public static Boolean IsPotentialHit(UIElement element, Point2D point)
{
if (element.Visibility != Visibility.Visible)
return false;
if (!element.IsHitTestVisible)
return false;
if (!element.VisualBounds.Contains(point))
return false;
var clip = element.ClipRectangle;
if (clip.HasValue)
{
var absoluteClip = clip.Value;
var relativeClip = new RectangleD(
absoluteClip.X - element.UntransformedAbsolutePosition.X,
absoluteClip.Y - element.UntransformedAbsolutePosition.Y,
absoluteClip.Width,
absoluteClip.Height);
if (!relativeClip.Contains(point))
return false;
}
return true;
}
示例9: CreateScatterPlot
public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY, string variableNameColor = "-") {
ScatterPlot scatterPlot = new ScatterPlot();
IList<double> xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX));
IList<double> yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY));
if (variableNameColor == null || variableNameColor == "-") {
List<Point2D<double>> points = new List<Point2D<double>>();
for (int i = 0; i < xValues.Count; i++) {
Point2D<double> point = new Point2D<double>(xValues[i], yValues[i]);
points.Add(point);
}
ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", points);
scatterPlot.Rows.Add(scdr);
} else {
var colorValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameColor));
var data = xValues.Zip(yValues, (x, y) => new { x, y }).Zip(colorValues, (v, c) => new { v.x, v.y, c }).ToList();
var gradients = ColorGradient.Colors;
int curGradient = 0;
int numColors = colorValues.Distinct().Count();
foreach (var colorValue in colorValues.Distinct()) {
var values = data.Where(x => x.c == colorValue);
var row = new ScatterPlotDataRow(
variableNameX + " - " + variableNameY + " (" + colorValue + ")",
"",
values.Select(v => new Point2D<double>(v.x, v.y)),
new ScatterPlotDataRowVisualProperties() { Color = gradients[curGradient] });
curGradient += gradients.Count / numColors;
scatterPlot.Rows.Add(row);
}
}
return scatterPlot;
}
示例10: Main
private static void Main()
{
Point p = new Point2D(1, 2);
IVisitor v = new Chebyshev();
p.Accept(v);
Console.WriteLine(p.Metric);
}
示例11: Main
static void Main(string[] args)
{
Point2D<int> dot2D = new Point2D<int>(10, 20);
dot2D.ToString();
Point3D dot3D = new Point3D(10, 20, 30);
dot3D.ToString();
}
示例12: ContieneElPunto
public static bool ContieneElPunto(this IEnumerable<Point2D> secuencia, Point2D punto)
{
foreach (var puntoEnSecuencia in secuencia)
if (punto == puntoEnSecuencia)
return true;
return false;
}
示例13: Add
public void Add(Point2D[] points)
{
foreach (Point2D pt in points)
{
Add(pt.X, pt.Y);
}
}
示例14: IsPointInPolygonTest2
public void IsPointInPolygonTest2(double x, double y, bool outcome)
{
var testPoint = new Point2D(x, y);
var testPoly = this.TestPolygon4();
Assert.AreEqual(outcome, Polygon2D.IsPointInPolygon(testPoint, testPoly));
}
示例15: Seek
/// <summary>
/// Seek a target in a 2-dimensional grid
/// </summary>
/// <param name="grid">The grid to search</param>
/// <param name="startPoint">The start point to seek from</param>
/// <param name="targetPoint">The target to seek to</param>
/// <returns>An array of points in world space needed to pass through to get to the target</returns>
/// <exception cref="ArgumentOutOfRangeException">
/// If the start or target are out of range of the grid
/// </exception>
public static Point2D[] Seek(GridNode2D[,] grid, Point2D startPoint, Point2D targetPoint)
{
return Seek(
grid, startPoint, targetPoint, true, DEFAULT_MOVEMENTCOST,
DEFAULT_DIAGONALCOST, DEFAULT_ASCENTCOST, DEFAULT_DESCENTCOST
);
}