本文整理汇总了C#中Axes类的典型用法代码示例。如果您正苦于以下问题:C# Axes类的具体用法?C# Axes怎么用?C# Axes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Axes类属于命名空间,在下文中一共展示了Axes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Lerp
public static Vector2 Lerp(this Vector2 vector, Vector2 target, float time, Axes axis)
{
vector.x = axis.Contains(Axes.X) && Mathf.Abs(target.x - vector.x) > epsilon ? Mathf.Lerp(vector.x, target.x, time) : vector.x;
vector.y = axis.Contains(Axes.Y) && Mathf.Abs(target.y - vector.y) > epsilon ? Mathf.Lerp(vector.y, target.y, time) : vector.y;
return vector;
}
示例2: Distance
public static float Distance(this Vector3 vector, Vector3 target, Axes axes)
{
float distance = 0f;
switch (axes)
{
case Axes.X:
distance = Mathf.Abs(vector.x - target.x);
break;
case Axes.Y:
distance = Mathf.Abs(vector.y - target.y);
break;
case Axes.Z:
distance = Mathf.Abs(vector.z - target.z);
break;
case Axes.XY:
distance = Vector2.Distance(vector, target);
break;
case Axes.XZ:
distance = Vector2.Distance(new Vector2(vector.x, vector.z), new Vector2(target.x, target.z));
break;
case Axes.YZ:
distance = Vector2.Distance(new Vector2(vector.y, vector.z), new Vector2(target.y, target.z));
break;
case Axes.XYZ:
distance = Vector3.Distance(vector, target);
break;
}
return distance;
}
示例3: GetAcceleration
/// <summary>
/// Get the acceleration of one axis in Gs.
/// </summary>
/// <param name="axis">The axis to read from.</param>
/// <returns>Acceleration of the ADXL345 in Gs.</returns>
public override double GetAcceleration(Axes axis)
{
byte[] transferBuffer = new byte[3];
transferBuffer[0] = (byte)((AddressRead | AddressMultiByte | DataRegister) + (byte)axis);
m_spi.Transaction(transferBuffer, transferBuffer, 3);
return BitConverter.ToInt16(transferBuffer, 1) * GsPerLSB;
}
示例4: Average
public static float Average(this Vector4 vector, Axes axis)
{
float average = 0;
int axisCount = 0;
if (axis.Contains(Axes.X)) {
average += vector.x;
axisCount += 1;
}
if (axis.Contains(Axes.Y)) {
average += vector.y;
axisCount += 1;
}
if (axis.Contains(Axes.Z)) {
average += vector.z;
axisCount += 1;
}
if (axis.Contains(Axes.W)) {
average += vector.w;
axisCount += 1;
}
return average / axisCount;
}
示例5: Average
public static float Average(this Vector3 vector, Axes axes)
{
float average = 0f;
int axisCount = 0;
if ((axes & Axes.X) != 0)
{
average += vector.x;
axisCount += 1;
}
if ((axes & Axes.Y) != 0)
{
average += vector.y;
axisCount += 1;
}
if ((axes & Axes.Z) != 0)
{
average += vector.z;
axisCount += 1;
}
return average / axisCount;
}
示例6: Div
public static Vector2 Div(this Vector2 vector, Vector2 otherVector, Axes axis)
{
vector.x = axis.Contains(Axes.X) ? vector.x / otherVector.x : vector.x;
vector.y = axis.Contains(Axes.Y) ? vector.y / otherVector.y : vector.y;
return vector;
}
示例7: Div
public static Vector3 Div(this Vector3 vector, Vector3 otherVector, Axes axis)
{
vector.x = axis.Contains(Axes.X) ? vector.x / otherVector.x : vector.x;
vector.y = axis.Contains(Axes.Y) ? vector.y / otherVector.y : vector.y;
vector.z = axis.Contains(Axes.Z) ? vector.z / otherVector.z : vector.z;
return vector;
}
示例8: SetY
/// <summary>
/// Sets the value of the Y axe.
/// </summary>
public Vector3 SetY (float y)
{
if (y != value.y)
{
value.y = y;
axes |= Axes.Y;
}
return value;
}
示例9: Div
public static Vector4 Div(this Vector4 vector, Vector4 otherVector, Axes axis)
{
vector.x = axis.Contains(Axes.X) ? vector.x / otherVector.x : vector.x;
vector.y = axis.Contains(Axes.Y) ? vector.y / otherVector.y : vector.y;
vector.z = axis.Contains(Axes.Z) ? vector.z / otherVector.z : vector.z;
vector.w = axis.Contains(Axes.W) ? vector.w / otherVector.w : vector.w;
return vector;
}
示例10: SetX
/// <summary>
/// Sets the value of the X axe.
/// </summary>
public Vector3 SetX (float x)
{
if (x != value.x)
{
value.x = x;
axes |= Axes.X;
}
return value;
}
示例11: CreateNodeTest
#pragma warning restore 649
private NodeSet CreateNodeTest (Axes axis, object nodeTest, ArrayList plist)
{
NodeSet test = CreateNodeTest (axis, nodeTest);
if (plist != null) {
for (int i = 0; i < plist.Count; i++)
test = new ExprFilter (test,
(Expression) plist [i]);
}
return test;
}
示例12: Ceil
public static Vector2 Ceil(this Vector2 vector, Axes axes)
{
if ((axes & Axes.X) != 0)
vector.x = Mathf.Ceil(vector.x);
if ((axes & Axes.Y) != 0)
vector.y = Mathf.Ceil(vector.y);
return vector;
}
示例13: Lerp
public static Vector2 Lerp(this Vector2 vector, Vector2 target, float time, Axes axes)
{
if ((axes & Axes.X) != 0 && Mathf.Abs(target.x - vector.x) > _epsilon)
vector.x = Mathf.Lerp(vector.x, target.x, time);
if ((axes & Axes.Y) != 0 && Mathf.Abs(target.y - vector.y) > _epsilon)
vector.y = Mathf.Lerp(vector.y, target.y, time);
return vector;
}
示例14: AccelerateTowards
public static void AccelerateTowards(this Rigidbody2D rigidbody, Vector2 targetAcceleration, float speed, InterpolationModes interpolation, Axes axis = Axes.XY)
{
switch (interpolation) {
case InterpolationModes.Quadratic:
rigidbody.SetVelocity(rigidbody.velocity.Lerp(targetAcceleration, Time.fixedDeltaTime * speed, axis), axis);
break;
case InterpolationModes.Linear:
rigidbody.SetVelocity(rigidbody.velocity.LerpLinear(targetAcceleration, Time.fixedDeltaTime * speed, axis), axis);
break;
}
}
示例15: Resolve
public static Axes Resolve(Axes axis1, Axes axis2)
{
if (axis1 == axis2)
throw new ArgumentException("Cannot resolve duplicate axes.");
if ((axis1 == Axes.X || axis1 == Axes.Y) && (axis2 == Axes.X || axis2 == Axes.Y))
return Axes.Z;
else if ((axis1 == Axes.X || axis1 == Axes.Z) && (axis2 == Axes.X || axis2 == Axes.Z))
return Axes.Y;
else
return Axes.X;
}