本文整理汇总了C#中Point2D类的典型用法代码示例。如果您正苦于以下问题:C# Point2D类的具体用法?C# Point2D怎么用?C# Point2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Point2D类属于命名空间,在下文中一共展示了Point2D类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:cartman300,项目名称:CatiaNET,代码行数:7,代码来源:FactoryExtensions.cs
示例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();
}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:42,代码来源:LineSegment.cs
示例3: Point2D_IsConstructedProperly
public void Point2D_IsConstructedProperly()
{
var result = new Point2D(123.45, 456.78);
TheResultingValue(result)
.ShouldBe(123.45, 456.78);
}
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:7,代码来源:Point2DTests.cs
示例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();
}
开发者ID:Fizzly,项目名称:MMesh,代码行数:31,代码来源:RenderUtility.cs
示例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;
}
开发者ID:Crome696,项目名称:ServUO,代码行数:7,代码来源:MahjongDealerIndicator.cs
示例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;
}
开发者ID:Crwth,项目名称:UltimaXNA,代码行数:7,代码来源:ExpandableScroll.cs
示例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);
}
开发者ID:arnebp,项目名称:tet-unity-angryeyebots,代码行数:13,代码来源:UnityGazeUtils.cs
示例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;
}
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:33,代码来源:HitTestUtil.cs
示例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;
}
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:35,代码来源:ScatterPlotContent.cs
示例10: Main
private static void Main()
{
Point p = new Point2D(1, 2);
IVisitor v = new Chebyshev();
p.Accept(v);
Console.WriteLine(p.Metric);
}
开发者ID:LukinEgor,项目名称:Design-Pattern,代码行数:7,代码来源:Visitor.cs
示例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();
}
开发者ID:makmen,项目名称:itstep-C-,代码行数:7,代码来源:Program.cs
示例12: ContieneElPunto
public static bool ContieneElPunto(this IEnumerable<Point2D> secuencia, Point2D punto)
{
foreach (var puntoEnSecuencia in secuencia)
if (punto == puntoEnSecuencia)
return true;
return false;
}
开发者ID:digi21,项目名称:UtilidadesDigi,代码行数:7,代码来源:UtilidadesSecuenciaPoint2D.cs
示例13: Add
public void Add(Point2D[] points)
{
foreach (Point2D pt in points)
{
Add(pt.X, pt.Y);
}
}
开发者ID:oozcitak,项目名称:BoxCulvert,代码行数:7,代码来源:Extents.cs
示例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));
}
开发者ID:chantsunman,项目名称:mathnet-spatial,代码行数:7,代码来源:Polygon2DTests.cs
示例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
);
}
开发者ID:PurpleKingdomGames,项目名称:CoreLibs,代码行数:17,代码来源:AStar.cs
示例16: Update
public void Update(GameTime gameTime, Point2D characterPosition)
{
if((characterPosition.X + Constant.WindowWidth / 2 <
OrusTheGame.Instance.GameInformation.Levels[OrusTheGame.Instance.GameInformation.CurrentLevelIndex].LevelBackground.Texture.Texture.Width &&
characterPosition.X - Constant.WindowWidth / 2 > 0) ||
characterPosition.X > this.Center.X + Constant.WindowWidth)
{
this.Center = new Point2D(characterPosition.X - Constant.WindowWidth / 2, 0);
this.Transform = Matrix.CreateScale(new Vector3(1, 1, 0)) *
Matrix.CreateTranslation(new Vector3(-this.Center.X, -this.Center.Y, 0));
}
if(characterPosition.X < this.Center.X)
{
this.Center = new Point2D(characterPosition.X - Constant.StartingPlayerXPosition, 0);
this.Transform = Matrix.CreateScale(new Vector3(1, 1, 0)) *
Matrix.CreateTranslation(new Vector3(-this.Center.X, -this.Center.Y, 0));
}
var levelWidth = OrusTheGame.Instance.GameInformation.Levels[OrusTheGame.Instance.GameInformation.CurrentLevelIndex].LevelBackground.Texture.Texture.Width;
if (this.Center.X + Constant.WindowWidth > levelWidth)
{
this.Center = new Point2D(levelWidth - Constant.WindowWidth, 0);
this.Transform = Matrix.CreateScale(new Vector3(1, 1, 0)) *
Matrix.CreateTranslation(new Vector3(-this.Center.X, -this.Center.Y, 0));
}
}
开发者ID:EvgeniYorgakiev,项目名称:Orus,代码行数:25,代码来源:Camera.cs
示例17: Message
public Message(uint id, IntPtr wParam, IntPtr lParam)
{
this.Id = id;
this.WParam = wParam;
this.LParam = lParam;
this.Point = new Point2D(LowWord(lParam), HighWord(lParam));
}
开发者ID:Crwth,项目名称:UltimaXNA,代码行数:7,代码来源:Message.cs
示例18: DoIntersect
// The main function that returns true if line segment 'p1q1'
// and 'p2q2' intersect.
static bool DoIntersect(Point2D p1, Point2D q1, Point2D p2, Point2D q2)
{
// Find the four orientations needed for general and
// special cases
int o1 = orientation(p1, q1, p2);
int o2 = orientation(p1, q1, q2);
int o3 = orientation(p2, q2, p1);
int o4 = orientation(p2, q2, q1);
// General case
if (o1 != o2 && o3 != o4)
return true;
// Special Cases
// p1, q1 and p2 are colinear and p2 lies on segment p1q1
if (o1 == 0 && onSegment(p1, p2, q1)) return true;
// p1, q1 and p2 are colinear and q2 lies on segment p1q1
if (o2 == 0 && onSegment(p1, q2, q1)) return true;
// p2, q2 and p1 are colinear and p1 lies on segment p2q2
if (o3 == 0 && onSegment(p2, p1, q2)) return true;
// p2, q2 and q1 are colinear and q1 lies on segment p2q2
if (o4 == 0 && onSegment(p2, q1, q2)) return true;
return false; // Doesn't fall in any of the above cases
}
开发者ID:kingofcrabs,项目名称:NetDesigner,代码行数:30,代码来源:Polygon.cs
示例19: IsEar
/// <summary>
/// Checks if a given set of points forms an ear for a given polygon
/// </summary>
/// <param name="polygonPoints">The points describing the polygon</param>
/// <param name="ear">The resulting ear, if applicable</param>
/// <returns>True if these points form an ear</returns>
private static bool IsEar(Point2D p1, Point2D p2, Point2D p3, List<Point2D> polygonPoints, out Triangle ear)
{
// for now, assign null to the ear
ear = null;
// Check if these points form a concave angle
//if (Point2D.CalculateAngle(p1, p2, p3) > 0)
// return false; // Can't be an ear
// Make a triangle from the given points
Triangle t = new Triangle(p1, p2, p3);
// Check all other points of the polygon, if one falls within this triangle, this isn't an ear
foreach (Point2D p in polygonPoints)
if (!p.Equals(p1) && !p.Equals(p2) && !p.Equals(p3))
if (Triangle.PointInTriangle(t, p))
return false;
// Sort our points counter-clockwise (this is how wpf indices-triangles face 'up')
t.Points = Point2D.SortPoints(true, p1, p2, p3).ToArray();
// This is an ear
ear = t;
// Remove the center point out of the polygon
polygonPoints.Remove(p1);
// Report succes
return true;
}
开发者ID:BjornDeRijcke,项目名称:OpenStreetMap-3D,代码行数:36,代码来源:Polygon.cs
示例20: Point2DEqualityTests
public void Point2DEqualityTests()
{
Point2D p1 = new Point2D();
Point2D p2 = Point2D.Empty;
Point2D p3 = Point2D.Zero;
Point2D p4 = new Point2D(0, 0);
Point2D p5 = new Point2D(9, 10);
Assert.AreEqual(p1, p2);
Assert.AreNotEqual(p1, p3);
Assert.AreEqual(p3, p4);
Assert.AreNotEqual(p1, p5);
Assert.AreNotEqual(p3, p5);
IVectorD v1 = p1;
IVectorD v2 = p2;
IVectorD v3 = p3;
IVectorD v4 = p4;
IVectorD v5 = p5;
Assert.AreEqual(v1, v2);
Assert.AreNotEqual(v1, v3);
Assert.AreEqual(v3, v4);
Assert.AreNotEqual(v1, v5);
Assert.AreNotEqual(v3, v5);
Assert.AreEqual(v5, p5);
}
开发者ID:sridhar19091986,项目名称:sharpmapcf,代码行数:28,代码来源:Point2DTests.cs
注:本文中的Point2D类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论