private static MathVector getCameraDirection(MathTransform cameraTransform, MathUtility mathUtils) { double[] canonicalRay = { 0, 0, 1 }; MathVector normalVector = mathUtils.CreateVector(canonicalRay); MathVector cameraDirection = normalVector.MultiplyTransform(cameraTransform); return(cameraDirection); }
public MathVector transformBack(MathVector alreadyTransformed) { // see http://help.solidworks.com/2012/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IMathTransform.html // for documentation about what this horrific hack might mean double[] mathTransform = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; MathVector newXAxis = mathUtils.CreateVector(cameraDirection.ArrayData).Normalise(); MathVector newYAxis = getRayFromNamedPoint("y-basis").Normalise(); MathVector newZAxis = getRayFromNamedPoint("z-basis").Normalise(); mathTransform[0] = newXAxis.ArrayData[0]; mathTransform[1] = newXAxis.ArrayData[1]; mathTransform[2] = newXAxis.ArrayData[2]; mathTransform[3] = newYAxis.ArrayData[0]; mathTransform[4] = newYAxis.ArrayData[1]; mathTransform[5] = newYAxis.ArrayData[2]; mathTransform[6] = newZAxis.ArrayData[0]; mathTransform[7] = newZAxis.ArrayData[1]; mathTransform[8] = newZAxis.ArrayData[2]; int translatex = 9, translatey = 10, translatez = 11; mathTransform[translatex] = centreOfVision.ArrayData[0]; mathTransform[translatey] = centreOfVision.ArrayData[1]; mathTransform[translatez] = centreOfVision.ArrayData[2]; int scale = 12; mathTransform[scale] = 1; return(alreadyTransformed.MultiplyTransform(mathUtils.CreateTransform(mathTransform))); }