本文整理汇总了C#中Point.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Point.Add方法的具体用法?C# Point.Add怎么用?C# Point.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point.Add方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getDistance
private int getDistance(int floor, Point fromLoc, Direction direction)
{
var toLoc = fromLoc.Add(direction.DirectionAsPoint());
return PlayingField.CanMoveHere(ref floor, fromLoc, toLoc, true)
? Distance[floor, toLoc.Y, toLoc.X]
: int.MaxValue;
}
示例2: Realign
public void Realign()
{
for (; Fraction > 1; Fraction -= 1)
Location = NextLocation;
for (; Fraction < 0; Fraction += 1)
Location = Location.Add(Direction.Opposite.DirectionAsPoint());
}
示例3: AddsVector
public void AddsVector()
{
var point = new Point(0, 0);
var vector = new Vector(1, 2);
var newPoint = point.Add(vector);
Assert.Equal(1, newPoint.X);
Assert.Equal(2, newPoint.Y);
}
示例4: Main
static void Main(string[] args)
{
Point pt1 = new Point(1, 1);
Point pt2 = new Point(2, 2);
Point pt3;
pt3 = pt1.Add(pt2);
Console.WriteLine("pt3: {0}:{1}", pt3.x, pt3.y);
}
示例5: Explore
public void Explore(int floor, Point fromLoc, int distance, Direction direction)
{
var toLoc = fromLoc.Add(direction.DirectionAsPoint());
if (!PlayingField.CanMoveHere(ref floor, fromLoc, toLoc, true))
return;
var here = Distance[floor, toLoc.Y, toLoc.X];
if (here != 0 && here < distance)
return; // already know shorter path
Distance[floor, toLoc.Y, toLoc.X] = distance;
foreach (var newDirection in Direction.AllDirections)
Explore(floor, toLoc, distance + 1, newDirection);
}
示例6: ToOriginCenteredLine
public static Line ToOriginCenteredLine(Point origin, Vector axis)
{
return Line.ByStartPointEndPoint(origin.Add(axis.Scale(-axisScaleFactor)),
origin.Add(axis.Scale(axisScaleFactor)));
}
示例7: FindTileNeighborDirections
/// <summary>
/// Finds the neighbor directions in relation to x,y.
/// </summary>
/// <returns>
/// The neighbor directions.
/// </returns>
/// <param name='x'>
/// X.
/// </param>
/// <param name='y'>
/// Y.
/// </param>
/// <param name='index'>
/// Index.
/// </param>
public Facing[] FindTileNeighborDirections(Point p, int index)
{
List<Facing> answer = new List<Facing> ();
List<Point> neighbors = GetNeighboringPoints (p.X, p.Y);
Facing f;
foreach (Point n in neighbors)
if (_tiles [n.X, n.Y].Index == index) {
if(n == p.Add(Assets.FacingDirection(Facing.North))) answer.Add (Facing.North);
else if(n == p.Add(Assets.FacingDirection(Facing.South))) answer.Add (Facing.South);
else if(n == p.Add(Assets.FacingDirection(Facing.East))) answer.Add (Facing.East);
else if(n == p.Add (Assets.FacingDirection(Facing.West))) answer.Add (Facing.West);
}
return answer.ToArray();;
}
示例8: ReadNmeaToKmlPoint
/// <summary>
/// Pointクラスのテスト
/// <para>NMEAファイルから測位点情報を読み出し、KMLへPoint情報として出力します。</para>
/// </summary>
public static void ReadNmeaToKmlPoint()
{
NmeaReader reader = new NmeaReader();
reader.OpenWithDialog(); // NMEAファイル読み出し
if (reader.IsOpen)
{
Blh[] pos = reader.GetPositions(); // 測位情報のうちから位置座標のみを取得
DateTime[] times = reader.GetDateTimes(); // 測位情報から時刻情報のみを取得
if (pos.Length != 0 && times.Length != 0)
{
Point point = new Point(pos[0], Icon.shaded_dot);
point.description = reader.FileName;
point.AddDescription("0");
point.AddDescription(pos[0].ToString());
point.AddDescription(times[0].ToString());
point.Time = new KML.Time.TimeStamp(times[0]);
if (pos.Length >= 1 && times.Length >= 1)
{
for (int i = 1; i < pos.Length && i < times.Length; i++)
{
if (!(pos[i].B == 0.0 && pos[i].L == 0.0)) // 未測位分は除く…最初の奴は例外(対処しようとすると結構長くなる)
{
Point p = new Point(pos[i]);
p.description = i.ToString();
p.AddDescription(pos[i].ToString());
p.AddDescription(times[i].ToString());
p.Time = new KML.Time.TimeStamp(times[i]);
point.Add(p);
}
}
}
// ファイル出力
// KML出力はUTF8で出力してください。
using (System.IO.StreamWriter fwriter = new System.IO.StreamWriter("NMEAtoPoint.kml", false, Encoding.UTF8))
{
try
{
fwriter.Write(point.GetKmlCode());
}
catch
{
// エラー処理があれば記述
}
}
}
}
return;
}
示例9: Intersect
//.........这里部分代码省略.........
{
current = t;
facehits[0] = MINY;
delta.Set(0.0f, -Threshold, 0.0f);
}
}
else if(t == current)
{
facehits[1] = MINY;
delta.SetY(-Threshold);
}
}
}
if(ray.GetDirection().GetZ() != 0.0)
{
t = -(ray.GetOrigin().GetZ() - OctFaces[MAXZ].GetVert(0).GetZ()) / ray.GetDirection().GetZ();
if(t > Threshold)
{
if(t > current)
{
intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
if((intersect.GetX() <= MAXXF.GetVert(0).GetX()) && (intersect.GetX() >= MINXF.GetVert(0).GetX()) &&
(intersect.GetY() <= MAXYF.GetVert(0).GetY()) && (intersect.GetY() >= MINYF.GetVert(0).GetY()))
{
current = t;
facehits[0] = MAXZ;
delta.Set(0.0f, 0.0f, Threshold);
}
}
else if(t == current)
{
if(facehits[1] < 0)
{
facehits[1] = MAXZ;
}
else
{
facehits[2] = MAXZ;
}
delta.SetZ(Threshold);
}
}
t = -(ray.GetOrigin().GetZ() - OctFaces[MINZ].GetVert(0).GetZ()) / ray.GetDirection().GetZ();
if(t > Threshold)
{
if(t > current)
{
intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
if((intersect.GetX() <= MAXXF.GetVert(0).GetX()) && (intersect.GetX() >= MINXF.GetVert(0).GetX()) &&
(intersect.GetY() <= MAXYF.GetVert(0).GetY()) && (intersect.GetY() >= MINYF.GetVert(0).GetY()))
{
current = t;
facehits[0] = MINZ;
delta.Set(0.0f, 0.0f, -Threshold);
}
}
else if(t == current)
{
if(facehits[1] < 0)
{
facehits[1] = MINZ;
}
else
{
facehits[2] = MINZ;
}
delta.SetZ(-Threshold);
}
}
}
if(facehits[0] >= MAXX)
{
intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, current);
intersect.Add(delta);
adjacent = Adjacent[facehits[0]];
if(facehits[1] >= MAXX)
{
if(adjacent != null)
{
adjacent = adjacent.GetAdjacent(facehits[1]);
if(facehits[2] >= MAXX)
{
if(adjacent != null)
{
adjacent = adjacent.GetAdjacent(facehits[2]);
}
else
{
adjacent = null;
}
}
}
else
{
adjacent = null;
}
}
}
return (adjacent);
}
示例10: RenderScene
/**
* RenderScene
*/
public void RenderScene(Canvas canvas, int width, int section, int nsections)
{
Vector view = camera.GetViewDir();
Vector up = camera.GetOrthoUp();
Vector plane = new Vector();
Vector horIncr = new Vector();
Vector vertIncr = new Vector();
double ylen = camera.GetFocalDist() * (double)Math.Tan(0.5f * camera.GetFOV());
double xlen = ylen * canvas.GetWidth() / canvas.GetHeight();
Point upleft = new Point();
Point upright = new Point();
Point lowleft = new Point();
Point basepoint = new Point();
Point current;
Ray eyeRay = new Ray();
int ypixel, xpixel;
RayID = 1;
plane.Cross(view, up);
view.Scale(camera.GetFocalDist());
up.Scale(ylen);
plane.Scale(-xlen);
upleft.FindCorner(view, up, plane, camera.GetPosition());
plane.Negate();
upright.FindCorner(view, up, plane, camera.GetPosition());
up.Negate();
plane.Negate();
lowleft.FindCorner(view, up, plane, camera.GetPosition());
horIncr.Sub(upright, upleft);
horIncr.Scale(horIncr.Length() / ((double)canvas.GetWidth()));
vertIncr.Sub(lowleft, upleft);
vertIncr.Scale(vertIncr.Length() / ((double)canvas.GetHeight()));
basepoint.Set(upleft.GetX() + 0.5f * (horIncr.GetX() + vertIncr.GetX()), upleft.GetY() + 0.5f * (horIncr.GetY() + vertIncr.GetY()),
upleft.GetZ() + 0.5f * (horIncr.GetZ() + vertIncr.GetZ()));
eyeRay.SetOrigin(camera.GetPosition());
int xstart = section * width / nsections;
int xend = xstart + width / nsections;
Console.WriteLine("+" + xstart + " to " + (xend - 1) + " by " + canvas.GetHeight());
for(ypixel = 0; ypixel < canvas.GetHeight(); ypixel++)
{
current = new Point(basepoint);
for(xpixel = 0; xpixel < canvas.GetWidth(); xpixel++)
{
if(xpixel >= xstart && xpixel < xend)
{
Color color = new Color(0.0f, 0.0f, 0.0f);
eyeRay.GetDirection().Sub(current, eyeRay.GetOrigin());
eyeRay.GetDirection().Normalize();
eyeRay.SetID(RayID);
this.RayID = this.RayID + 1;
Shade(octree, eyeRay, color, 1.0f, 0, 0);
canvas.Write(Brightness, xpixel, ypixel, color);
}
current.Add(horIncr);
}
basepoint.Add(vertIncr);
}
Console.WriteLine("-" + xstart + " to " + (xend - 1) + " by " + canvas.GetHeight());
}