本文整理汇总了C#中IPoint类的典型用法代码示例。如果您正苦于以下问题:C# IPoint类的具体用法?C# IPoint怎么用?C# IPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IPoint类属于命名空间,在下文中一共展示了IPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public void Create()
{
var points = new IPoint[,]
{
{new Point(0.0, 1.0), new Point(0.0, 0.0)},
{new Point(0.5, 1.5), new Point(1.0, 0.0)},
{new Point(1.0, 2.0), new Point(2.0, 2.0)}
};
var coverage = new DiscreteGridPointCoverage(3, 2, points.Cast<IPoint>());
var values = new[,]
{
{1.0, 2.0},
{3.0, 4.0},
{5.0, 6.0}
};
coverage.SetValues(values);
/*
var coverageLayer = new DiscreteGridPointCoverageLayer { Coverage = coverage, ShowFaces = true };
var map = new Map { Layers = { coverageLayer } };
MapTestHelper.Show(map);
*/
var value = coverage.Evaluate(points[1, 1].Coordinate);
const double expectedValue = 4.0;
Assert.AreEqual(expectedValue, value);
Assert.IsTrue(coverage.Components[0].Values.Cast<double>().SequenceEqual(new [] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }));
Assert.AreEqual("new grid point coverage", coverage.Name);
}
示例2: CalcDistanceBetweenTwoPointsIn2D
public static double CalcDistanceBetweenTwoPointsIn2D(IPoint firstPoint, IPoint secondPoint)
{
double distance = Math.Sqrt((secondPoint.X - firstPoint.X) * (secondPoint.X - firstPoint.X) +
(secondPoint.Y - firstPoint.Y) * (secondPoint.Y - firstPoint.Y));
return distance;
}
示例3: SqlGeometryToGeometryMultiPoint
private static IGeometry SqlGeometryToGeometryMultiPoint(SqlGeometry geometry, GeometryFactory factory)
{
IPoint[] points = new IPoint[geometry.STNumGeometries().Value];
for (int i = 1; i <= points.Length; i++)
points[i - 1] = SqlGeometryToGeometryPoint(geometry.STGeometryN(i), factory);
return factory.CreateMultiPoint(points);
}
示例4: GetPositionImprovement
public static float GetPositionImprovement(IPoint source, IPoint target, int turns)
{
float dSource = (float)Goal.Other.GetDistance(source);
float dTarget = (float)Goal.Other.GetDistance(target);
var gain = dSource- dTarget;
return gain / (float)turns;
}
示例5: addSplitPt
public void addSplitPt(IPoint startPt, IPoint endPt)
{
LineEndPt lineEnd = new LineEndPt();
lineEnd.startPt = startPt;
lineEnd.endPt = endPt;
splitLineEndPtArray.Add(lineEnd);
}
示例6: HouseManager
public HouseManager(IPoint llPt, House h, CommonHouse ch)
{
//四个角的点是外面圈的四个顶点, 因为在进行计算时, 一直以外圈为准.
lowerLeftPt = new PointClass();
lowerLeftPt.X = llPt.X;
lowerLeftPt.Y = llPt.Y;
house = h;
commonHouse = ch;
lowerRightPt = new PointClass();
lowerRightPt.X = lowerLeftPt.X + house.leftGap + house.width + house.rightGap;
lowerRightPt.Y = lowerLeftPt.Y;
upperLeftPt = new PointClass();
upperLeftPt.X = lowerLeftPt.X;
upperLeftPt.Y = lowerLeftPt.Y + commonHouse.frontGap + commonHouse.height + commonHouse.backGap;
upperRightPt = new PointClass();
upperRightPt.X = lowerRightPt.X;
upperRightPt.Y = upperLeftPt.Y;
southDirctionPt = new PointClass();
southDirctionPt.X = (lowerLeftPt.X + lowerRightPt.X) / 2;
southDirctionPt.Y = lowerLeftPt.Y;
rotateAngle = 0;
}
示例7: Create
public void Create()
{
var points = new IPoint[,]
{
{new Point(0, 0), new Point(1, 0)},
{new Point(2, 1), new Point(3, 1.5)},
{new Point(1, 2), new Point(3, 3)}
};
var coverage = new DiscreteGridPointCoverage(3, 2, points.Cast<IPoint>());
var values = new[,]
{
{1.0, 2.0},
{3.0, 4.0},
{5.0, 6.0}
};
coverage.SetValues(values);
var value = coverage.Evaluate(points[1, 1].Coordinate);
const double expectedValue = 4.0;
Assert.AreEqual(expectedValue, value);
Assert.IsTrue(coverage.Components[0].Values.Cast<double>().SequenceEqual(new [] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }));
Assert.AreEqual("new grid point coverage", coverage.Name);
}
示例8: IsOnField
public bool IsOnField(IPoint point) {
return
!IsLeft(point) &&
!IsRight(point) &&
!IsAbove(point) &&
!IsUnder(point);
}
示例9: Read
/// <summary>
/// Reads a stream and converts the shapefile record to an equilivant geometry object.
/// </summary>
/// <param name="file">The stream to read.</param>
/// <param name="geometryFactory">The geometry factory to use when making the object.</param>
/// <returns>The Geometry object that represents the shape file record.</returns>
public override IGeometry Read(BigEndianBinaryReader file, IGeometryFactory geometryFactory)
{
int shapeTypeNum = file.ReadInt32();
type = (ShapeGeometryType) Enum.Parse(typeof(ShapeGeometryType), shapeTypeNum.ToString());
if (type == ShapeGeometryType.NullShape)
return geometryFactory.CreateMultiPoint(new IPoint[] { });
if (!(type == ShapeGeometryType.MultiPoint || type == ShapeGeometryType.MultiPointM ||
type == ShapeGeometryType.MultiPointZ || type == ShapeGeometryType.MultiPointZM))
throw new ShapefileException("Attempting to load a non-multipoint as multipoint.");
// Read and for now ignore bounds.
int bblength = GetBoundingBoxLength();
bbox = new double[bblength];
for (; bbindex < 4; bbindex++)
{
double d = file.ReadDouble();
bbox[bbindex] = d;
}
// Read points
int numPoints = file.ReadInt32();
IPoint[] points = new IPoint[numPoints];
for (int i = 0; i < numPoints; i++)
{
double x = file.ReadDouble();
double y = file.ReadDouble();
IPoint point = geometryFactory.CreatePoint(new Coordinate(x, y));
points[i] = point;
}
geom = geometryFactory.CreateMultiPoint(points);
GrabZMValues(file);
return geom;
}
示例10: Contains
public bool Contains(IPoint point)
{
var crossProduct = (point.YCoordinate - StartingPoint.YCoordinate)*
(EndingPoint.XCoordinate - StartingPoint.XCoordinate) -
(point.XCoordinate - StartingPoint.XCoordinate)*
(EndingPoint.YCoordinate - StartingPoint.YCoordinate);
if (Math.Abs(crossProduct) > Double.Epsilon)
return false;
var dotProduct = (point.XCoordinate - StartingPoint.XCoordinate)*
(EndingPoint.XCoordinate - StartingPoint.XCoordinate) +
(point.YCoordinate - StartingPoint.YCoordinate)*
(EndingPoint.YCoordinate - StartingPoint.YCoordinate);
if (dotProduct < 0)
return false;
var squaredLength = (EndingPoint.XCoordinate - StartingPoint.XCoordinate)*
(EndingPoint.XCoordinate - StartingPoint.XCoordinate) +
(EndingPoint.YCoordinate - StartingPoint.YCoordinate)*
(EndingPoint.YCoordinate - StartingPoint.YCoordinate);
if (dotProduct > squaredLength)
return false;
return true;
}
示例11: CreatePartial
public static IPartialEvaluator CreatePartial(IPoint point)
{
// It's important for efficiency that the same objects are reused whenever possible. Thus no compact memory
// implementation of IPartialEvaluator (like InnerCompactEvaluator; but in that case only primitive types
// are returned, i.e. doubles).
return new InnerPartialEvaluator(point);
}
示例12: Rotate
public static IPoint Rotate( this IPoint point, double degrees, IPoint pivot )
{
var translate = new Point( pivot.X * -1, pivot.Y * -1 );
var translatedPoint = point.Translate( translate );
var rotatedPoint = translatedPoint.Rotate( degrees );
return rotatedPoint.Translate( pivot );
}
示例13: DragOperation
public DragOperation(ICanvasItem child, IPoint startingPoint, ISnappingEngine snappingEngine)
{
SnappingEngine = snappingEngine;
Child = child;
StartingPoint = startingPoint;
ChildStartingPoint = child.GetPosition();
}
示例14: IpoptOptimizerResult
public IpoptOptimizerResult(bool status, bool hasConverged, IPoint optimalPoint, double optimalValue, IpoptReturnCode returnCode, int iterations)
: base(status, optimalPoint, optimalValue)
{
HasConverged = hasConverged;
ReturnCode = returnCode;
Iterations = iterations;
}
示例15: UpdateHandlePosition
public void UpdateHandlePosition(IPoint newPoint)
{
var rect = Child.Rect();
if (InsideLimitsX(newPoint.X) && CanChangeHorizontalPosition)
{
var left = Math.Min(newPoint.X, Opposite.X);
var right = Math.Max(newPoint.X, Opposite.X);
rect.X = left;
rect.SetRightKeepingLeft(right);
}
if (InsideLimitsY(newPoint.Y) && CanChangeVerticalPosition)
{
var top = Math.Min(newPoint.Y, Opposite.Y);
var bottom = Math.Max(newPoint.Y, Opposite.Y);
rect.Y = top;
rect.SetBottomKeepingTop(bottom);
}
if (rect.Width > 0 && rect.Height > 0)
{
SnappingEngine.SetSourceRectForResize(rect);
}
}