Exemple #1
0
 public void Scale(FVec4 scale)
 {
     this.x *= scale.x;
     this.y *= scale.y;
     this.z *= scale.z;
     this.w *= scale.w;
 }
Exemple #2
0
 public bool AproxEqualsBox(FVec4 vector, Fix64 tolerance)
 {
     return
         ((Fix64.Abs(this.x - vector.x) <= tolerance) &&
          (Fix64.Abs(this.y - vector.y) <= tolerance) &&
          (Fix64.Abs(this.z - vector.z) <= tolerance) &&
          (Fix64.Abs(this.w - vector.w) <= tolerance));
 }
Exemple #3
0
        public static FVec4 NormalizeSafe(FVec4 v)
        {
            Fix64 dis = Fix64.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w);

            if (dis == Fix64.Zero)
            {
                return(new FVec4());
            }
            return(v * (Fix64.One / dis));
        }
Exemple #4
0
        public static FVec4 ClampMagnitude(FVec4 v, Fix64 maxLength)
        {
            FVec4 nor          = v;
            Fix64 sqrMagnitude = nor.SqrMagnitude();

            if (sqrMagnitude > (maxLength * maxLength))
            {
                nor = nor * (maxLength / Fix64.Sqrt(sqrMagnitude));
            }
            return(nor);
        }
Exemple #5
0
        public FVec4 UnProject(FMat4 viewProjInverse, Fix64 viewX, Fix64 viewY, Fix64 viewWidth, Fix64 viewHeight)
        {
            FVec4 result = this;

            result.x = (result.x - viewX) / viewWidth;
            result.y = (result.y - viewY) / viewHeight;
            result   = result * Fix64.Two - Fix64.One;

            result = result.Transform(viewProjInverse);
            Fix64 wDelta = Fix64.One / result.w;

            result.x *= wDelta;
            result.y *= wDelta;
            result.z *= wDelta;

            return(result);
        }
Exemple #6
0
        public FVec4 Project(FMat4 projectionMatrix, FMat4 viewMatrix, Fix64 viewX, Fix64 viewY, Fix64 viewWidth, Fix64 viewHeight)
        {
            FVec4 result = this;

            result = result.Multiply(viewMatrix);
            result = result.Multiply(projectionMatrix);

            Fix64 wDelta = Fix64.One / result.w;

            result.x *= wDelta;
            result.y *= wDelta;
            result.z *= wDelta;

            result.x = result.x * Fix64.Half + Fix64.Half;
            result.y = result.y * Fix64.Half + Fix64.Half;
            result.z = result.z * Fix64.Half + Fix64.Half;

            result.x = result.x * viewWidth + viewX;
            result.y = result.y * viewHeight + viewY;

            return(result);
        }
Exemple #7
0
 public static FVec4 Lerp(FVec4 from, FVec4 to, Fix64 t)
 {
     return(t <= Fix64.Zero ? @from : (t >= Fix64.One ? to : LerpUnclamped(@from, to, t)));
 }
Exemple #8
0
 public static FVec4 LerpUnclamped(FVec4 from, FVec4 to, Fix64 t)
 {
     return(new FVec4(from.x + (to.x - from.x) * t, from.y + (to.y - from.y) * t, from.z + (to.z - from.z) * t, from.w + (to.w - from.w) * t));
 }
Exemple #9
0
 public Fix64 DistanceSquared(FVec4 vector)
 {
     return((vector - this).Dot());
 }
Exemple #10
0
 public static FVec4 Floor(FVec4 v)
 {
     return(new FVec4(Fix64.Floor(v.x), Fix64.Floor(v.y), Fix64.Floor(v.z),
                      Fix64.Floor(v.w)));
 }
Exemple #11
0
 public static FVec4 Abs(FVec4 v)
 {
     return(new FVec4(Fix64.Abs(v.x), Fix64.Abs(v.y), Fix64.Abs(v.z), Fix64.Abs(v.w)));
 }
Exemple #12
0
 public static Fix64 DistanceSquared(FVec4 v0, FVec4 v1)
 {
     return((v1 - v0).Dot());
 }
Exemple #13
0
 public static Fix64 Distance(FVec4 v0, FVec4 v1)
 {
     return((v1 - v0).Magnitude());
 }
Exemple #14
0
 public bool ApproxEquals(FVec4 vector, Fix64 tolerance)
 {
     return(this.Distance(vector) <= tolerance);
 }
Exemple #15
0
 public Fix64 Dot(FVec4 vector)
 {
     return(this.x * vector.x + this.y * vector.y + this.z * vector.z + this.w * vector.w);
 }
Exemple #16
0
 public static FVec4 Min(FVec4 v, Fix64 value)
 {
     return(new FVec4(Fix64.Min(v.x, value), Fix64.Min(v.y, value), Fix64.Min(v.z, value),
                      Fix64.Min(v.w, value)));
 }
Exemple #17
0
 public static FVec4 Min(FVec4 v, FVec4 values)
 {
     return(new FVec4(Fix64.Min(v.x, values.x), Fix64.Min(v.y, values.y), Fix64.Min(v.z, values.z),
                      Fix64.Min(v.w, values.w)));
 }
Exemple #18
0
 public static FVec4 Normalize(FVec4 v)
 {
     return(v * (Fix64.One / Fix64.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w)));
 }
Exemple #19
0
 public static FVec4 Pow(FVec4 v, Fix64 power)
 {
     return(new FVec4(Fix64.Pow(v.x, power), Fix64.Pow(v.y, power),
                      Fix64.Pow(v.z, power), Fix64.Pow(v.w, power)));
 }
Exemple #20
0
 public static Fix64 Dot(FVec4 v0, FVec4 v1)
 {
     return(v0.x * v1.x + v0.y * v1.y + v0.z * v1.z + v0.w * v1.w);
 }
Exemple #21
0
 public static FVec4 Round(FVec4 v)
 {
     return(new FVec4(Fix64.Round(v.x), Fix64.Round(v.y), Fix64.Round(v.z),
                      Fix64.Round(v.w)));
 }
Exemple #22
0
 public Fix64 Distance(FVec4 vector)
 {
     return((vector - this).Magnitude());
 }