Задача 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 F64Vector2 GetNormalized()
|
||||
{
|
||||
double squareModule = this.GetSquareModule();
|
||||
|
||||
if (1.0 - F64Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0 + F64Utility.TWO_EPSYLON)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
if (squareModule <= F64Utility.SQUARE_EPSYLON)
|
||||
{
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
double module = Math.Sqrt(squareModule);
|
||||
|
||||
return new F64Vector2(
|
||||
this.x1 / module,
|
||||
this.x2 / module
|
||||
);
|
||||
}
|
||||
|
||||
public void Reverse()
|
||||
{
|
||||
this.x1 = -this.x1;
|
||||
|
|
@ -156,6 +134,12 @@ namespace BGC
|
|||
this.x2 = -vector.x2;
|
||||
}
|
||||
|
||||
public void AppendScaled(F64Vector2 scalableSummand, double scale)
|
||||
{
|
||||
this.x1 += scalableSummand.x1 * scale;
|
||||
this.x2 += scalableSummand.x2 * scale;
|
||||
}
|
||||
|
||||
public readonly override string ToString()
|
||||
{
|
||||
return String.Format("DPVector2({0}, {1})", this.x1, this.x2);
|
||||
|
|
@ -185,92 +169,18 @@ namespace BGC
|
|||
quotient.x2 = dividend.x2 / divisor;
|
||||
}
|
||||
|
||||
public static void GetWeightedSum2(
|
||||
double weight1, in F64Vector2 vector1,
|
||||
double weight2, in F64Vector2 vector2,
|
||||
out F64Vector2 sum
|
||||
)
|
||||
{
|
||||
sum.x1 = vector1.x1 * weight1 + vector2.x1 * weight2;
|
||||
sum.x2 = vector1.x2 * weight1 + vector2.x2 * weight2;
|
||||
}
|
||||
|
||||
public static void GetWeightedSum3(
|
||||
double weight1, in F64Vector2 vector1,
|
||||
double weight2, in F64Vector2 vector2,
|
||||
double weight3, in F64Vector2 vector3,
|
||||
out F64Vector2 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(
|
||||
double weight1, in F64Vector2 vector1,
|
||||
double weight2, in F64Vector2 vector2,
|
||||
double weight3, in F64Vector2 vector3,
|
||||
double weight4, in F64Vector2 vector4,
|
||||
out F64Vector2 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(
|
||||
double weight1, in F64Vector2 vector1,
|
||||
double weight2, in F64Vector2 vector2,
|
||||
double weight3, in F64Vector2 vector3,
|
||||
double weight4, in F64Vector2 vector4,
|
||||
double weight5, in F64Vector2 vector5,
|
||||
out F64Vector2 sum)
|
||||
{
|
||||
sum.x1 = (vector1.x1 * weight1 + vector2.x1 * weight2) + (vector3.x1 * weight3 + vector4.x1 * weight4) + vector5.x1 * weight5;
|
||||
sum.x2 = (vector1.x2 * weight1 + vector2.x2 * weight2) + (vector3.x2 * weight3 + vector4.x2 * weight4) + vector5.x2 * weight5;
|
||||
}
|
||||
|
||||
public static void GetMean2(
|
||||
in F64Vector2 vector1,
|
||||
in F64Vector2 vector2,
|
||||
out F64Vector2 result)
|
||||
public static void GetMean2(in F64Vector2 vector1, in F64Vector2 vector2, out F64Vector2 result)
|
||||
{
|
||||
result.x1 = (vector1.x1 + vector2.x1) * 0.5;
|
||||
result.x2 = (vector1.x2 + vector2.x2) * 0.5;
|
||||
}
|
||||
|
||||
public static void GetMean3(
|
||||
in F64Vector2 vector1,
|
||||
in F64Vector2 vector2,
|
||||
in F64Vector2 vector3,
|
||||
out F64Vector2 result)
|
||||
public static void GetMean3(in F64Vector2 vector1, in F64Vector2 vector2, in F64Vector2 vector3, out F64Vector2 result)
|
||||
{
|
||||
result.x1 = (vector1.x1 + vector2.x1 + vector3.x1) * F64Utility.ONE_THIRD;
|
||||
result.x2 = (vector1.x2 + vector2.x2 + vector3.x2) * F64Utility.ONE_THIRD;
|
||||
}
|
||||
|
||||
public static void GetMean4(
|
||||
in F64Vector2 vector1,
|
||||
in F64Vector2 vector2,
|
||||
in F64Vector2 vector3,
|
||||
in F64Vector2 vector4,
|
||||
out F64Vector2 result)
|
||||
{
|
||||
result.x1 = ((vector1.x1 + vector2.x1) + (vector3.x1 + vector4.x1)) * 0.25;
|
||||
result.x2 = ((vector1.x2 + vector2.x2) + (vector3.x2 + vector4.x2)) * 0.25;
|
||||
}
|
||||
|
||||
public static void GetMean5(
|
||||
in F64Vector2 vector1,
|
||||
in F64Vector2 vector2,
|
||||
in F64Vector2 vector3,
|
||||
in F64Vector2 vector4,
|
||||
in F64Vector2 vector5,
|
||||
out F64Vector2 result)
|
||||
{
|
||||
result.x1 = ((vector1.x1 + vector2.x1) + (vector3.x1 + vector4.x1) + vector5.x1) * 0.2;
|
||||
result.x2 = ((vector1.x2 + vector2.x2) + (vector3.x2 + vector4.x2) + vector5.x2) * 0.2;
|
||||
}
|
||||
|
||||
public static double GetScalarProduct(in F64Vector2 vector1, in F64Vector2 vector2)
|
||||
{
|
||||
return vector1.x1 * vector2.x1 + vector1.x2 * vector2.x2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue