本文整理汇总了C#中Coordinates类的典型用法代码示例。如果您正苦于以下问题:C# Coordinates类的具体用法?C# Coordinates怎么用?C# Coordinates使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Coordinates类属于命名空间,在下文中一共展示了Coordinates类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LocalMapCluster
public LocalMapCluster(Coordinates position, double speed, Coordinates heading, double width)
{
this.position = position;
this.speed = speed;
this.heading = heading;
this.width = width;
}
示例2: CreateRover
public static Rover CreateRover(string definition)
{
if (string.IsNullOrEmpty(definition)) throw new WrongRoverDefinitionException("Definition of rover is empty.");
var coordinatesAndOrientation = definition.Split(' ');
if(coordinatesAndOrientation.Length != 3) throw new WrongRoverDefinitionException("Definition of rover doesn't have the proper format.");
Coordinates coordinates;
IOrientation orientation;
try
{
coordinates = new Coordinates(Convert.ToInt32(coordinatesAndOrientation[0]),
Convert.ToInt32(coordinatesAndOrientation[1]));
orientation = OrientationFactory.GenerateOrientation(coordinatesAndOrientation[2]);
}
catch (Exception ex)
{
throw new WrongRoverDefinitionException("Bad definition.", ex);
}
var rover = new Rover();
rover.Init(coordinates, orientation);
return rover;
}
示例3: ComputeMeanCovariance
public static void ComputeMeanCovariance(IList<Coordinates> pts, out Coordinates mean, out Matrix2 cov)
{
// for better numerical stability, use a two-pass method where we first compute the mean
double sum_x = 0, sum_y = 0;
for (int i = 0; i < pts.Count; i++) {
sum_x += pts[i].X;
sum_y += pts[i].Y;
}
double avg_x = sum_x/(double)pts.Count;
double avg_y = sum_y/(double)pts.Count;
// now compute variances and covariances
double sum_x2 = 0, sum_y2 = 0, sum_xy = 0;
for (int i = 0; i < pts.Count; i++) {
double dx = pts[i].X - avg_x;
double dy = pts[i].Y - avg_y;
sum_x2 += dx*dx;
sum_y2 += dy*dy;
sum_xy += dx*dy;
}
double var_x = sum_x2/(double)pts.Count;
double var_y = sum_y2/(double)pts.Count;
double cov_xy = sum_xy/(double)pts.Count;
mean = new Coordinates(avg_x, avg_y);
cov = new Matrix2(var_x, cov_xy, cov_xy, var_y);
}
示例4: CreatePolygon
public static SqlGeography CreatePolygon(Coordinates[] coordinates, int srid)
{
var list = coordinates.Distinct().ToList();
var b = new SqlGeographyBuilder();
b.SetSrid(srid);
b.BeginGeography(OpenGisGeographyType.Polygon);
b.BeginFigure(list[0].Latitude, list[0].Longitude);
for (var i = 1; i < list.Count; i++)
b.AddLine(list[i].Latitude, list[i].Longitude);
b.AddLine(list[0].Latitude, list[0].Longitude);
b.EndFigure();
b.EndGeography();
//Fix left-hand rule. We always want left-hand.
var g = b.ConstructedGeography;
if (!g.STIsValid())
throw new SisoDbException(ExceptionMessages.NotAValidPolygon.Inject(g.IsValidDetailed()));
if (g.EnvelopeAngle() > 90)
g = g.ReorientObject();
return g;
}
示例5: WillCollideWith
private bool WillCollideWith(GameObject obj, Coordinates direction, GameObject cur)
{
Coordinates first = new Coordinates(
Math.Max(obj.Position.Row + direction.Row,
cur.Position.Row),
Math.Max(obj.Position.Col + direction.Col,
cur.Position.Col)
);
Coordinates last = new Coordinates(
Math.Min(obj.Position.Row + obj.Rows + direction.Row,
cur.Position.Row + cur.Rows),
Math.Min(obj.Position.Col + obj.Cols + direction.Col,
cur.Position.Col + cur.Cols)
);
for (int row = first.Row; row < last.Row; row++)
for (int col = first.Col; col < last.Col; col++)
if (obj[row - obj.Position.Row - direction.Row, col - obj.Position.Col - direction.Col] != '\0' &&
cur[row - cur.Position.Row, col - cur.Position.Col] != '\0')
return true;
return false;
}
示例6: Map
public Map(PhysicsEngine physicsEngine)
{
physicsEngine.AddItem(this);
this.physicsEngine = physicsEngine;
RequeredTicksToMove = 3;
Position = new Coordinates();
Content = new Dictionary<Coordinates, char>();
for (int i = 0; i < mapFences.Length; i++)
{
mapFences[i] = new char[Globals.Y_MAX_BOARD_SIZE];
for (int j = 0; j < mapFences[i].Length; j++)
{
mapFences[i][j] = j % 3 == 1 ? Globals.BACKGROUND_DEFAULT_VALUE : '+';
}
}
var jsonText = File.ReadAllText(Globals.MODELS_PATH + "asd" + Globals.MODELS_FILES_EXTENSION);
var deserializeObject = JsonConvert.DeserializeObject<MapStructure>(jsonText);
Width = deserializeObject.MapWidth;
Height = deserializeObject.MapLength;
foreach (var mapObject in deserializeObject.map)
{
switch (mapObject.ClassType)
{
case "Services.Services.Objects.Obsticle":
TakeObject(obsticlesFactory, mapObject);
break;
default:
return;
}
}
RecreateFences();
}
示例7: EvaluateGoalUtility
private static double EvaluateGoalUtility(double curvature, Coordinates relativeGoalPoint)
{
// get the angle to the goal point
double angle = relativeGoalPoint.ArcTan;
const double angleMax = 45*Math.PI/180.0;
double scaledAngle = angle/angleMax;
if (scaledAngle > 1) scaledAngle = 1;
if (scaledAngle < -1) scaledAngle = -1;
// calculate the target curvature to hit the goal
double targetCurvature = scaledAngle*max_curvature;
// calculate a matching scale factor
double scaleFactor = Math.Pow((curvature - targetCurvature)/0.01, 2);
// calculate a distance weighting factor
double distMin = 20;
double distMax = 70;
double distFactor = (relativeGoalPoint.Length - distMin)/(distMax - distMin);
if (distFactor > 0.3) distFactor = 0.3;
if (distFactor < 0) distFactor = 0;
distFactor = 1-distFactor;
double turnFactor = (1-scaleFactor*0.1);
if (turnFactor < -1) turnFactor = -1;
return turnFactor*distFactor;
}
示例8: getBlockAt
public Block getBlockAt(Coordinates coordinates)
{
int x = (int)Math.Floor(coordinates.getX());
int y = (int)Math.Floor(coordinates.getY());
if(!blocks.ContainsKey(x.ToString() + "," + y.ToString())){
if (coordinates.getY() > -1) {
blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Air()));
}
else if (coordinates.getY() == -1) {
blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Grass()));
}
else if (coordinates.getY() == -2) {
Random rnd = new Random();
if (rnd.Next(0, 2) == 0) {
blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Dirt()));
}
else {
blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Stone()));
}
}
else if (coordinates.getY() < -2) {
blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Stone()));
}
blocks[x.ToString() + "," + y.ToString()].setCoordinates(coordinates);
}
return blocks[x.ToString() + "," + y.ToString()];
}
示例9: GetCoordinates
public JsonResult GetCoordinates(string street, string number)
{
var reguestGET =
WebRequest.Create("http://nominatim.openstreetmap.org/search?q=" + number + "+" + street +
",+Донецк, Украина&format=xml&addressdetails=1");
reguestGET.Proxy = null;
var webResponse = reguestGET.GetResponse();
var stream = webResponse.GetResponseStream();
if (stream == null)
{
throw new Exception("Can't get response from server.");
}
var xmlDoc = new XmlDocument();
xmlDoc.Load(stream);
var tagPlace = (XmlElement) xmlDoc.GetElementsByTagName("place")[0];
if (tagPlace == null)
{
return Json(null, JsonRequestBehavior.AllowGet);
}
var lat = Convert.ToSingle(tagPlace.GetAttribute("lat"), new CultureInfo("en-US"));
var lon = Convert.ToSingle(tagPlace.GetAttribute("lon"), new CultureInfo("en-US"));
var coord = new Coordinates { Lat = lat, Lon = lon };
return Json(coord, JsonRequestBehavior.AllowGet);
}
示例10: WhenACoordinateHasBeenExploredThenIsExploredIsTrue
public void WhenACoordinateHasBeenExploredThenIsExploredIsTrue()
{
var minefield = Minefield.Empty(2, 3);
var coordinate = new Coordinates(0, 1);
var exploredMinefield = minefield.Explore(coordinate);
Assert.AreEqual(true, exploredMinefield.IsExplored(coordinate.RowIndex, coordinate.ColumnIndex));
}
示例11: getCell
public WorldCell getCell(Coordinates cell_coords)
{
if (checkCoordinateIntegrity (cell_coords)) {
return cells[cell_coords.x, cell_coords.y];
}
return null;
}
示例12: isEqual
public bool isEqual(Coordinates coordinate)
{
if(coordinate.x == x && coordinate.y == y) {
return true;
}
return false;
}
示例13: LinePathSegment
public LinePathSegment(Coordinates start, Coordinates end, double? endSpeed, bool? stopline)
{
this.start = start;
this.end = end;
this.endSpeed = endSpeed;
this.stopline = stopline;
}
示例14: ClearForDisabledVehiclePass
/// <summary>
/// Checks if hte opposing lane is clear to pass an opposing vehicle
/// </summary>
/// <param name="lane"></param>
/// <param name="state"></param>
/// <returns></returns>
public bool ClearForDisabledVehiclePass(ArbiterLane lane, VehicleState state, double vUs, Coordinates minReturn)
{
// update the forward vehicle
this.ForwardVehicle.Update(lane, state);
// check if the rear vehicle exists and is moving along with us
if (this.ForwardVehicle.ShouldUseForwardTracker && this.ForwardVehicle.CurrentVehicle != null)
{
// distance from other to us
double currentDistance = lane.DistanceBetween(this.ForwardVehicle.CurrentVehicle.ClosestPosition, state.Front) - (2 * TahoeParams.VL);
double minChangeDist = lane.DistanceBetween(minReturn, state.Front);
// check if he's within min return dist
if(currentDistance > minChangeDist)
{
// params
double vOther = this.ForwardVehicle.CurrentVehicle.StateMonitor.Observed.speedValid ? this.ForwardVehicle.CurrentVehicle.Speed : lane.Way.Segment.SpeedLimits.MaximumSpeed;
// get distance of envelope for him to slow to our speed
double xEnvelope = (Math.Pow(vUs, 2.0) - Math.Pow(vOther, 2.0)) / (2.0 * -0.5);
// check to see if vehicle is outside of the envelope to slow down for us after 3 seconds
double xSafe = currentDistance - minChangeDist - (xEnvelope + (vOther * 15.0));
return xSafe > 0 ? true : false;
}
else
return false;
}
else
return true;
}
示例15: AddBlockage
/// <summary>
/// Add blockage to partition
/// </summary>
/// <param name="partition"></param>
/// <param name="c"></param>
public void AddBlockage(IConnectAreaWaypoints partition, Coordinates c, bool acrossSegment)
{
partition.Blockage.BlockageExists = true;
partition.Blockage.BlockageCoordinates = c;
partition.Blockage.SecondsSinceObserved = 0.0;
partition.Blockage.BlockageTimeCost = 1800;
if (partition.Blockage.BlockageHasExisted)
partition.Blockage.BlockageLifetime = partition.Blockage.BlockageLifetime * 4.0;
if (acrossSegment && partition is ArbiterLanePartition)
{
foreach (ArbiterLanePartition alp in ((ArbiterLanePartition)partition).NonLaneAdjacentPartitions)
{
if (alp.IsInside(c))
{
alp.Blockage.BlockageExists = true;
alp.Blockage.BlockageCoordinates = c;
alp.Blockage.SecondsSinceObserved = 0.0;
alp.Blockage.BlockageTimeCost = 1800;
if (alp.Blockage.BlockageHasExisted)
alp.Blockage.BlockageLifetime = partition.Blockage.BlockageLifetime * 4.0;
}
}
}
// reset navigation costs
this.currentTimes = new KeyValuePair<int, Dictionary<ArbiterWaypointId, DownstreamPointOfInterest>>();
}