//"Spin" = rotate around a relative center of motion :o) //---------------------------------------------------------------- public void Spin(float radians, IVector3H1 axisUnitVector, IVector3H1 RelCenter) { Matrix4X4 Trans1 = new Matrix4X4(); //translate relative center to oragine Trans1.SetTranslate(-(Vector3H1)RelCenter); //have to cast to object not interface type to apply operator Matrix4X4 RotateMat = new Matrix4X4(); RotateMat.RotateAnyAxis(radians, axisUnitVector); //Do 3D rotation Matrix4X4 Trans2 = new Matrix4X4(); Trans2.SetTranslate(RelCenter); // put it back IMatrix4D Answer = Trans2 * RotateMat * Trans1; //multiply out answer this.Copy(Answer); }
//"stretch" = scale around a relative (quasi-center) point //basically you move to the origin, do a normal scale, then move the object back public void Stretch(float SX, float SY, float SZ, IVector3H1 RelCenter) //probably cannot be done in 3x3... 3H4??? { //translate relative center to oragine Matrix4X4 Trans1 = new Matrix4X4(); Trans1.SetTranslate(-RelCenter.X, -RelCenter.Y, -RelCenter.Z); //do the scaling Matrix4X4 ScaleMat = new Matrix4X4(); ScaleMat.SetScale(SX, SY, SZ); // put it back Matrix4X4 Trans2 = new Matrix4X4(); Trans2.SetTranslate(RelCenter); IMatrix4D Answer = Trans2 * ScaleMat * Trans1; this.Copy(Answer); }
public Matrix3H4(IMatrix4D OtherMatrix) //copy constructor { Data = new float[3, 4]; this.Copy(OtherMatrix); }
//Can only be done in Square Matricies unless you allow for generic sizes which are not yet supported public void SetTranspose() { IMatrix4D Transpose = this.GetTranspose(); this.Copy(Transpose); }