/** * Gets the result of adding a matrix to this. * * @param Other The Matrix to add. * @return The result of addition. */ public static FMatrix operator+(FMatrix This, FMatrix Other) { FMatrix ResultMat = new FMatrix(); for (int X = 0; X < 4; X++) { for (int Y = 0; Y < 4; Y++) { ResultMat[X, Y] = This[X, Y] + Other[X, Y]; } } return(ResultMat); }
/** * This isn't applying SCALE, just multiplying float to all members - i.e. weighting */ public static FMatrix operator*(FMatrix This, float Other) { FMatrix ResultMat = new FMatrix(); for (int X = 0; X < 4; X++) { for (int Y = 0; Y < 4; Y++) { ResultMat[X, Y] = This[X, Y] * Other; } } return(ResultMat); }
/** * Checks whether another Matrix is equal to this, within specified tolerance. * * @param Other The other Matrix. * @param Tolerance Error Tolerance. * @return true if two Matrix are equal, within specified tolerance, otherwise false. */ public override bool Equals(object Obj) { FMatrix Other = (FMatrix)Obj; float Tolerance = Const.KINDA_SMALL_NUMBER; for (int X = 0; X < 4; X++) { for (int Y = 0; Y < 4; Y++) { if (FMath.Abs(this[X, Y] - Other[X, Y]) > Tolerance) { return(false); } } } return(true); }
public void SetFromMatrix(FMatrix InMatrix) { FMatrix M = InMatrix; // Get the 3D scale from the matrix Scale3D = M.ExtractScaling(); // If there is negative scaling going on, we handle that here if (InMatrix.Determinant() < 0.0f) { // Assume it is along X and modify transform accordingly. // It doesn't actually matter which axis we choose, the 'appearance' will be the same Scale3D.X *= -1.0f; M.SetAxis(0, -M.GetScaledAxis(EAxis.X)); } Rotation = new FQuat(M); Translation = InMatrix.GetOrigin(); // Normalize rotation Rotation.Normalize(); }
//[MethodImplAttribute(MethodImplOptions.InternalCall)] extern static FMatrix TransposeAdjoint(ref FMatrix This);
//[MethodImplAttribute(MethodImplOptions.InternalCall)] extern static FMatrix Inverse(ref FMatrix This);
/** * Transform a direction vector by the inverse of this matrix - will not take into account translation part. * If you want to transform a surface normal (or plane) and correctly account for non-uniform scaling you should use TransformByUsingAdjointT with adjoint of matrix inverse. */ public FVector InverseTransformVector(FVector V) { FMatrix InvSelf = this.InverseFast(); return(InvSelf.TransformVector(V)); }
//[MethodImplAttribute(MethodImplOptions.InternalCall)] extern static FVector4 TransformFVector4(ref FMatrix This, ref FVector4 V);
public void SetFromMatrix(FMatrix inMatrix) => E_FTransform_SetFromMatrix(this, inMatrix);
//[MethodImplAttribute(MethodImplOptions.InternalCall)] extern static FRotator Rotator(ref FMatrix This);
//[MethodImplAttribute(MethodImplOptions.InternalCall)] extern static FMatrix ConcatTranslation(ref FMatrix This, ref FVector Translation);
public FQuat(FMatrix M) { this = MakeFromMatrix(M); }
public static FQuat MakeFromMatrix(FMatrix Matrix) { return(MakeFromMatrix(ref Matrix)); }
//[MethodImplAttribute(MethodImplOptions.InternalCall)] extern static FQuat MakeFromMatrix(ref FMatrix Matrix);
/// <summary> /// Constructor /// </summary> /// <param name="srcProjMat">source projection matrix to premultiply with the clip matrix</param> /// <param name="plane">clipping plane used to build the clip matrix (assumed to be in camera space)</param> public FClipProjectionMatrix(FMatrix srcProjMat, FPlane plane) : base(E_CreateStruct_FClipProjectionMatrix_FMatrix_FPlane(srcProjMat, plane), false) { }
/// <summary> /// Constructor for converting a Matrix (including scale) into a FTransform. /// </summary> public FTransform(FMatrix inMatrix) : base(E_CreateStruct_FTransform_FMatrix(inMatrix), false) { }
//[MethodImplAttribute(MethodImplOptions.InternalCall)] extern static void RemoveScaling(ref FMatrix This, float Tolerance);
public FInstancedStaticMeshInstanceData(FMatrix inTransform) : base(E_CreateStruct_FInstancedStaticMeshInstanceData_FMatrix(inTransform), false) { }
//[MethodImplAttribute(MethodImplOptions.InternalCall)] extern static FVector ExtractScaling(ref FMatrix This, float Tolerance);
//[MethodImplAttribute(MethodImplOptions.InternalCall)] extern static void Mirror(ref FMatrix This, int MirrorAxis, int FlipAxis);
//[MethodImplAttribute(MethodImplOptions.InternalCall)] extern static FMatrix ApplyScale(ref FMatrix This, float Scale);
static extern bool GetFrustumTopPlane(ref FMatrix This, out FPlane OutPlane);
//[MethodImplAttribute(MethodImplOptions.InternalCall)] extern static bool GetFrustumBottomPlane(ref FMatrix This, out FPlane OutPlane);
/// <summary> /// Creates and initializes a new quaternion from the given matrix. /// </summary> /// <param name="m">The rotation matrix to initialize from.</param> public FQuat(FMatrix m) : base(E_CreateStruct_FQuat_FMatrix(m), false) { }
//[MethodImplAttribute(MethodImplOptions.InternalCall)] extern static FMatrix Multiply(ref FMatrix This, ref FMatrix Other);
static extern FMatrix InverseFast(ref FMatrix This);