Задача 0000002: замена методов getWeightedSum на appendScaled для векторов / Task 0000002: replacement of getWeightedSum methods on appendScaled for vectors
This commit is contained in:
parent
f9bf5ef92e
commit
c3dc0b2ecd
4 changed files with 35 additions and 417 deletions
|
|
@ -81,28 +81,6 @@ namespace BGC
|
|||
return 1;
|
||||
}
|
||||
|
||||
public readonly F32Vector2 GetNormalized()
|
||||
{
|
||||
float squareModule = this.GetSquareModule();
|
||||
|
||||
if (1.0f - F32Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0f + F32Utility.TWO_EPSYLON)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
if (squareModule <= F32Utility.SQUARE_EPSYLON)
|
||||
{
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
float module = MathF.Sqrt(squareModule);
|
||||
|
||||
return new F32Vector2(
|
||||
this.x1 / module,
|
||||
this.x2 / module
|
||||
);
|
||||
}
|
||||
|
||||
public void Reverse()
|
||||
{
|
||||
this.x1 = -this.x1;
|
||||
|
|
@ -155,6 +133,13 @@ namespace BGC
|
|||
this.x1 = -(float)vector.x1;
|
||||
this.x2 = -(float)vector.x2;
|
||||
}
|
||||
|
||||
public void AppendScaled(F32Vector2 scalableSummand, float scale)
|
||||
{
|
||||
this.x1 += scalableSummand.x1 * scale;
|
||||
this.x2 += scalableSummand.x2 * scale;
|
||||
}
|
||||
|
||||
public readonly override string ToString()
|
||||
{
|
||||
return String.Format("SPVector2({0}, {1})", this.x1, this.x2);
|
||||
|
|
@ -184,98 +169,18 @@ namespace BGC
|
|||
quotient.x2 = dividend.x2 / divisor;
|
||||
}
|
||||
|
||||
public static void GetWeightedSum2(
|
||||
float weight1, in F32Vector2 vector1,
|
||||
float weight2, in F32Vector2 vector2,
|
||||
out F32Vector2 sum
|
||||
)
|
||||
{
|
||||
sum.x1 = vector1.x1 * weight1 + vector2.x1 * weight2;
|
||||
sum.x2 = vector1.x2 * weight1 + vector2.x2 * weight2;
|
||||
}
|
||||
|
||||
public static void GetWeightedSum3(
|
||||
float weight1, in F32Vector2 vector1,
|
||||
float weight2, in F32Vector2 vector2,
|
||||
float weight3, in F32Vector2 vector3,
|
||||
out F32Vector2 sum
|
||||
)
|
||||
{
|
||||
sum.x1 = vector1.x1 * weight1 + vector2.x1 * weight2 + vector3.x1 * weight3;
|
||||
sum.x2 = vector1.x2 * weight1 + vector2.x2 * weight2 + vector3.x2 * weight3;
|
||||
}
|
||||
|
||||
public static void GetWeightedSum4(
|
||||
float weight1, in F32Vector2 vector1,
|
||||
float weight2, in F32Vector2 vector2,
|
||||
float weight3, in F32Vector2 vector3,
|
||||
float weight4, in F32Vector2 vector4,
|
||||
out F32Vector2 sum
|
||||
)
|
||||
{
|
||||
sum.x1 = (vector1.x1 * weight1 + vector2.x1 * weight2) + (vector3.x1 * weight3 + vector4.x1 * weight4);
|
||||
sum.x2 = (vector1.x2 * weight1 + vector2.x2 * weight2) + (vector3.x2 * weight3 + vector4.x2 * weight4);
|
||||
}
|
||||
|
||||
public static void GetWeightedSum5(
|
||||
float weight1, in F32Vector2 vector1,
|
||||
float weight2, in F32Vector2 vector2,
|
||||
float weight3, in F32Vector2 vector3,
|
||||
float weight4, in F32Vector2 vector4,
|
||||
float weight5, in F32Vector2 vector5,
|
||||
out F32Vector2 sum
|
||||
)
|
||||
{
|
||||
sum.x1 = (vector1.x1 * weight1 + vector2.x1 * weight2) + (vector3.x1 * weight3 + vector4.x1 * weight4);
|
||||
sum.x2 = (vector1.x2 * weight1 + vector2.x2 * weight2) + (vector3.x2 * weight3 + vector4.x2 * weight4);
|
||||
}
|
||||
|
||||
public static void GetMean2(
|
||||
in F32Vector2 vector1,
|
||||
in F32Vector2 vector2,
|
||||
out F32Vector2 result
|
||||
)
|
||||
public static void GetMean2(in F32Vector2 vector1, in F32Vector2 vector2, out F32Vector2 result)
|
||||
{
|
||||
result.x1 = (vector1.x1 + vector2.x1) * 0.5f;
|
||||
result.x2 = (vector1.x2 + vector2.x2) * 0.5f;
|
||||
}
|
||||
|
||||
public static void GetMean3(
|
||||
in F32Vector2 vector1,
|
||||
in F32Vector2 vector2,
|
||||
in F32Vector2 vector3,
|
||||
out F32Vector2 result
|
||||
)
|
||||
public static void GetMean3(in F32Vector2 vector1, in F32Vector2 vector2, in F32Vector2 vector3, out F32Vector2 result)
|
||||
{
|
||||
result.x1 = (vector1.x1 + vector2.x1 + vector3.x1) * F32Utility.ONE_THIRD;
|
||||
result.x2 = (vector1.x2 + vector2.x2 + vector3.x2) * F32Utility.ONE_THIRD;
|
||||
}
|
||||
|
||||
public static void GetMean4(
|
||||
in F32Vector2 vector1,
|
||||
in F32Vector2 vector2,
|
||||
in F32Vector2 vector3,
|
||||
in F32Vector2 vector4,
|
||||
out F32Vector2 result
|
||||
)
|
||||
{
|
||||
result.x1 = ((vector1.x1 + vector2.x1) + (vector3.x1 + vector4.x1)) * 0.25f;
|
||||
result.x2 = ((vector1.x2 + vector2.x2) + (vector3.x2 + vector4.x2)) * 0.25f;
|
||||
}
|
||||
|
||||
public static void GetMean5(
|
||||
in F32Vector2 vector1,
|
||||
in F32Vector2 vector2,
|
||||
in F32Vector2 vector3,
|
||||
in F32Vector2 vector4,
|
||||
in F32Vector2 vector5,
|
||||
out F32Vector2 result
|
||||
)
|
||||
{
|
||||
result.x1 = ((vector1.x1 + vector2.x1) + (vector3.x1 + vector4.x1) + vector5.x1) * 0.2f;
|
||||
result.x2 = ((vector1.x2 + vector2.x2) + (vector3.x2 + vector4.x2) + vector5.x2) * 0.2f;
|
||||
}
|
||||
|
||||
public static float GetScalarProduct(in F32Vector2 vector1, in F32Vector2 vector2)
|
||||
{
|
||||
return vector1.x1 * vector2.x1 + vector1.x2 * vector2.x2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue