Удаление избыточных методов и реорганизация библиотеки / Removing of extra methods and reorganization of the library

This commit is contained in:
Andrey Pokidov 2024-11-15 19:11:49 +07:00
parent 301cabe8de
commit c38c5ac857
14 changed files with 969 additions and 1583 deletions

View file

@ -109,18 +109,13 @@ namespace Geometry
);
}
public void Invert()
public void Reverse()
{
this.x1 = -this.x1;
this.x2 = -this.x2;
this.x3 = -this.x3;
}
public readonly DPVector3 GetInverted()
{
return new DPVector3(-this.x1, -this.x2, -this.x3);
}
public readonly bool IsZero()
{
return this.GetSquareModule() <= DPUtility.SQUARE_EPSYLON;
@ -146,6 +141,13 @@ namespace Geometry
this.x3 = x3;
}
public void SetValues(in DPVector3 vector)
{
this.x1 = vector.x1;
this.x2 = vector.x2;
this.x3 = vector.x3;
}
public void SetValues(in SPVector3 vector)
{
this.x1 = vector.x1;
@ -153,11 +155,18 @@ namespace Geometry
this.x3 = vector.x3;
}
public void SetValues(in DPVector3 vector)
public void SetReverseOf(in DPVector3 vector)
{
this.x1 = vector.x1;
this.x2 = vector.x2;
this.x3 = vector.x3;
this.x1 = -vector.x1;
this.x2 = -vector.x2;
this.x3 = -vector.x3;
}
public void SetReverseOf(in SPVector3 vector)
{
this.x1 = -vector.x1;
this.x2 = -vector.x2;
this.x3 = -vector.x3;
}
public readonly override string ToString()
@ -172,45 +181,6 @@ namespace Geometry
sum.x3 = vector1.x3 + vector2.x3;
}
public static void Add3(
in DPVector3 vector1,
in DPVector3 vector2,
in DPVector3 vector3,
out DPVector3 sum
)
{
sum.x1 = vector1.x1 + vector2.x1 + vector3.x1;
sum.x2 = vector1.x2 + vector2.x2 + vector3.x2;
sum.x3 = vector1.x3 + vector2.x3 + vector3.x3;
}
public static void Add4(
in DPVector3 vector1,
in DPVector3 vector2,
in DPVector3 vector3,
in DPVector3 vector4,
out DPVector3 sum
)
{
sum.x1 = (vector1.x1 + vector2.x1) + (vector3.x1 + vector4.x1);
sum.x2 = (vector1.x2 + vector2.x2) + (vector3.x2 + vector4.x2);
sum.x3 = (vector1.x3 + vector2.x3) + (vector3.x3 + vector4.x3);
}
public static void Add5(
in DPVector3 vector1,
in DPVector3 vector2,
in DPVector3 vector3,
in DPVector3 vector4,
in DPVector3 vector5,
out DPVector3 sum
)
{
sum.x1 = (vector1.x1 + vector2.x1) + (vector3.x1 + vector4.x1) + vector5.x1;
sum.x2 = (vector1.x2 + vector2.x2) + (vector3.x2 + vector4.x2) + vector5.x2;
sum.x3 = (vector1.x3 + vector2.x3) + (vector3.x3 + vector4.x3) + vector5.x3;
}
public static void Subtract(in DPVector3 minuend, in DPVector3 subtrahend, out DPVector3 difference)
{
difference.x1 = minuend.x1 - subtrahend.x1;
@ -218,56 +188,6 @@ namespace Geometry
difference.x3 = minuend.x3 - subtrahend.x3;
}
public static void GetWeightedSum2(
double weight1, in DPVector3 vector1,
double weight2, in DPVector3 vector2,
out DPVector3 sum
)
{
sum.x1 = vector1.x1 * weight1 + vector2.x1 * weight2;
sum.x2 = vector1.x2 * weight1 + vector2.x2 * weight2;
sum.x3 = vector1.x3 * weight1 + vector2.x3 * weight2;
}
public static void GetWeightedSum3(
double weight1, in DPVector3 vector1,
double weight2, in DPVector3 vector2,
double weight3, in DPVector3 vector3,
out DPVector3 sum
)
{
sum.x1 = vector1.x1 * weight1 + vector2.x1 * weight2 + vector3.x1 * weight3;
sum.x2 = vector1.x2 * weight1 + vector2.x2 * weight2 + vector3.x2 * weight3;
sum.x3 = vector1.x3 * weight1 + vector2.x3 * weight2 + vector3.x3 * weight3;
}
public static void GetWeightedSum4(
double weight1, in DPVector3 vector1,
double weight2, in DPVector3 vector2,
double weight3, in DPVector3 vector3,
double weight4, in DPVector3 vector4,
out DPVector3 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);
sum.x3 = (vector1.x3 * weight1 + vector2.x3 * weight2) + (vector3.x3 * weight3 + vector4.x3 * weight4);
}
public static void GetWeightedSum5(
double weight1, in DPVector3 vector1,
double weight2, in DPVector3 vector2,
double weight3, in DPVector3 vector3,
double weight4, in DPVector3 vector4,
double weight5, in DPVector3 vector5,
out DPVector3 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;
sum.x3 = (vector1.x3 * weight1 + vector2.x3 * weight2) + (vector3.x3 * weight3 + vector4.x3 * weight4) + vector5.x3 * weight5;
}
public static void Muliply(in DPVector3 multiplicand, double multiplier, out DPVector3 product)
{
product.x1 = multiplicand.x1 * multiplier;
@ -282,11 +202,56 @@ namespace Geometry
quotient.x3 = dividend.x3 / divisor;
}
public static void GetWeightedSum2(
double weight1, in DPVector3 vector1,
double weight2, in DPVector3 vector2,
out DPVector3 sum)
{
sum.x1 = vector1.x1 * weight1 + vector2.x1 * weight2;
sum.x2 = vector1.x2 * weight1 + vector2.x2 * weight2;
sum.x3 = vector1.x3 * weight1 + vector2.x3 * weight2;
}
public static void GetWeightedSum3(
double weight1, in DPVector3 vector1,
double weight2, in DPVector3 vector2,
double weight3, in DPVector3 vector3,
out DPVector3 sum)
{
sum.x1 = vector1.x1 * weight1 + vector2.x1 * weight2 + vector3.x1 * weight3;
sum.x2 = vector1.x2 * weight1 + vector2.x2 * weight2 + vector3.x2 * weight3;
sum.x3 = vector1.x3 * weight1 + vector2.x3 * weight2 + vector3.x3 * weight3;
}
public static void GetWeightedSum4(
double weight1, in DPVector3 vector1,
double weight2, in DPVector3 vector2,
double weight3, in DPVector3 vector3,
double weight4, in DPVector3 vector4,
out DPVector3 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);
sum.x3 = (vector1.x3 * weight1 + vector2.x3 * weight2) + (vector3.x3 * weight3 + vector4.x3 * weight4);
}
public static void GetWeightedSum5(
double weight1, in DPVector3 vector1,
double weight2, in DPVector3 vector2,
double weight3, in DPVector3 vector3,
double weight4, in DPVector3 vector4,
double weight5, in DPVector3 vector5,
out DPVector3 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;
sum.x3 = (vector1.x3 * weight1 + vector2.x3 * weight2) + (vector3.x3 * weight3 + vector4.x3 * weight4) + vector5.x3 * weight5;
}
public static void GetMean2(
in DPVector3 vector1,
in DPVector3 vector2,
out DPVector3 result
)
out DPVector3 result)
{
result.x1 = (vector1.x1 + vector2.x1) * 0.5;
result.x2 = (vector1.x2 + vector2.x2) * 0.5;
@ -297,8 +262,7 @@ namespace Geometry
in DPVector3 vector1,
in DPVector3 vector2,
in DPVector3 vector3,
out DPVector3 result
)
out DPVector3 result)
{
result.x1 = (vector1.x1 + vector2.x1 + vector3.x1) * DPUtility.ONE_THIRD;
result.x2 = (vector1.x2 + vector2.x2 + vector3.x2) * DPUtility.ONE_THIRD;
@ -310,8 +274,7 @@ namespace Geometry
in DPVector3 vector2,
in DPVector3 vector3,
in DPVector3 vector4,
out DPVector3 result
)
out DPVector3 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;
@ -324,8 +287,7 @@ namespace Geometry
in DPVector3 vector3,
in DPVector3 vector4,
in DPVector3 vector5,
out DPVector3 result
)
out DPVector3 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;