本文整理汇总了C#中System.Vector2.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2.ToString方法的具体用法?C# Vector2.ToString怎么用?C# Vector2.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector2
的用法示例。
在下文中一共展示了Vector2.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnScroll
public override bool OnScroll (MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
{
if ((TouchPanel.EnabledGestures & GestureType.FreeDrag) != 0)
{
if (!dragging) dragging = true;
Vector2 position = new Vector2(e2.GetX(), e2.GetY());
Android.Util.Log.Info("MonoGame", position.ToString());
AndroidGameActivity.Game.Window.UpdateTouchPosition(ref position);
var gs = new GestureSample(GestureType.FreeDrag, AndroidGameActivity.Game.TargetElapsedTime,
position, Vector2.Zero, Vector2.Zero, Vector2.Zero);
TouchPanel.GestureList.Enqueue(gs);
}
return base.OnScroll (e1, e2, distanceX, distanceY);
}
示例2: MergeWithBounding
/// <summary>
/// A new version of terrain merge that processes the terrain in a specific order and corrects the problems with rotated terrains
/// having 'holes' in that need to be smoothed. The correct way to rotate something is to iterate over the target, taking data from
/// the source, not the other way around. This ensures that the target has no holes in it.
/// The processing order of an incoming terrain is:
/// 1. Apply rotation
/// 2. Apply bounding rectangle
/// 3. Apply displacement
/// rotationCenter is no longer needed and has been discarded.
/// </summary>
/// <param name="newTerrain"></param>
/// <param name="displacement"><x, y, z></param>
/// <param name="rotationDegrees"></param>
/// <param name="boundingOrigin"><x, y></param>
/// <param name="boundingSize"><x, y></param>
public void MergeWithBounding(ITerrainChannel newTerrain, Vector3 displacement, float rotationDegrees, Vector2 boundingOrigin, Vector2 boundingSize)
{
m_log.DebugFormat("{0} MergeWithBounding: inSize=<{1},{2}>, rot={3}, boundingOrigin={4}, boundingSize={5}, disp={6}, outSize=<{7},{8}>",
LogHeader, newTerrain.Width, newTerrain.Height, rotationDegrees, boundingOrigin.ToString(),
boundingSize.ToString(), displacement, m_terrainData.SizeX, m_terrainData.SizeY);
// get the size of the incoming terrain
int baseX = newTerrain.Width;
int baseY = newTerrain.Height;
// create an intermediate terrain map that is 25% bigger on each side that we can work with to handle rotation
int offsetX = baseX / 4; // the original origin will now be at these coordinates so now we can have imaginary negative coordinates ;)
int offsetY = baseY / 4;
int tmpX = baseX + baseX / 2;
int tmpY = baseY + baseY / 2;
int centreX = tmpX / 2;
int centreY = tmpY / 2;
TerrainData terrain_tmp = new HeightmapTerrainData(tmpX, tmpY, (int)Constants.RegionHeight);
for (int xx = 0; xx < tmpX; xx++)
for (int yy = 0; yy < tmpY; yy++)
terrain_tmp[xx, yy] = -65535f; //use this height like an 'alpha' mask channel
double radianRotation = Math.PI * rotationDegrees / 180f;
double cosR = Math.Cos(radianRotation);
double sinR = Math.Sin(radianRotation);
if (rotationDegrees < 0f) rotationDegrees += 360f; //-90=270 -180=180 -270=90
// So first we apply the rotation to the incoming terrain, storing the result in terrain_tmp
// We special case orthogonal rotations for accuracy because even using double precision math, Math.Cos(90 degrees) is never fully 0
// and we can never rotate around a centre 'pixel' because the 'bitmap' size is always even
int x, y, sx, sy;
for (y = 0; y <= tmpY; y++)
{
for (x = 0; x <= tmpX; x++)
{
if (rotationDegrees == 0f)
{
sx = x - offsetX;
sy = y - offsetY;
}
else if (rotationDegrees == 90f)
{
sx = y - offsetX;
sy = tmpY - 1 - x - offsetY;
}
else if (rotationDegrees == 180f)
{
sx = tmpX - 1 - x - offsetX;
sy = tmpY - 1 - y - offsetY;
}
else if (rotationDegrees == 270f)
{
sx = tmpX - 1 - y - offsetX;
sy = x - offsetY;
}
else
{
// arbitary rotation: hmmm should I be using (centreX - 0.5) and (centreY - 0.5) and round cosR and sinR to say only 5 decimal places?
sx = centreX + (int)Math.Round((((double)x - centreX) * cosR) + (((double)y - centreY) * sinR)) - offsetX;
sy = centreY + (int)Math.Round((((double)y - centreY) * cosR) - (((double)x - centreX) * sinR)) - offsetY;
}
if (sx >= 0 && sx < baseX && sy >= 0 && sy < baseY)
{
try
{
terrain_tmp[x, y] = (float)newTerrain[sx, sy];
}
catch (Exception) //just in case we've still not taken care of every way the arrays might go out of bounds! ;)
{
m_log.DebugFormat("{0} MergeWithBounding - Rotate: Out of Bounds sx={1} sy={2} dx={3} dy={4}", sx, sy, x, y);
}
}
}
}
// We could also incorporate the next steps, bounding-rectangle and displacement in the loop above, but it's simpler to visualise if done separately
// and will also make it much easier when later I want the option for maybe a circular or oval bounding shape too ;).
int newX = m_terrainData.SizeX;
int newY = m_terrainData.SizeY;
// displacement is relative to <0,0> in the destination region and defines where the origin of the data selected by the bounding-rectangle is placed
int dispX = (int)Math.Floor(displacement.X);
int dispY = (int)Math.Floor(displacement.Y);
//.........这里部分代码省略.........
示例3: Vector2ToStringTest
public void Vector2ToStringTest()
{
Vector2 target = new Vector2(1.0f, 2.2f);
string expected = "{X:1 Y:2.2}";
string actual;
actual = target.ToString();
Assert.AreEqual(expected, actual, "Vector2.ToString did not return the expected value.");
}
示例4: TestMemberFn_ToString_i
public void TestMemberFn_ToString_i ()
{
Vector2 a = new Vector2(42, -17);
String result = a.ToString();
String expected = "{X:42 Y:-17}";
Assert.That(result, Is.EqualTo(expected));
}
示例5: GetPathStore
public static SimPathStore GetPathStore(Vector2 loc)
{
lock (_PathStores)
{
SimPathStore PS;
if (_PathStores.TryGetValue(loc,out PS)) {
return PS;
}
PS = new SimPathStore(loc.ToString(), loc, new Vector3d(loc.X * 256, loc.Y * 256, 0), new Vector3(256, 256, Single.MaxValue));
return PS;
}
}