public void ViewTransformation_RotateAndTranslate_SetOnCamera() { // From text - never quite sure what order to apply composite transforms. // But just tried reversing order and got the right answer! var transformBuilder = new MatrixTransformationBuilder() .Translate(_translation) .RotateY(_firstRotation); _cameraInstance.SetViewTransformation(transformBuilder); }
private IMatrixTransformationBuilder GetActualResult_Natural() { // More natural way of chaining transformations. // The builder does the RMF/CMF conversion and // reverses the transformation order for final calculation. IMatrixTransformationBuilder builder = new MatrixTransformationBuilder(); return(builder .RotateX(_firstRotation) .Scale(_scale) .Translate(_translation)); }
public static void DrawClock(string outputBitmapFilePath) { using var canvas = new System.Drawing.Bitmap(50, 50); // Canvas is 50 x 50. (REM top-left = 0,0). // Centre of clock in centre of canvas @ 25, 25. // Let clock radius be 3/8 of canvas width: // r = 50*3/8 = 18.75 // For our Ray Tracer calculations P(0,0,0) is the // centre of the canvas. All calculations will be // based off this. So when plotting the final bitmap // pixel, add +25 to the x and y. // Script: // It should be something like this: // - start with hour 1, going up to hour 12. // - rotate (hour * Pi/6) radians around X-(??)axis. // - translate 18.75 points straight up Y-(??)axis. // - plot pixel. /****** UPDATE ****** * Got this working, but worth pointing out that a fair bit of trail and error and changing order and axis etc. * So would need to work through this example again, with reference to the Text ad ensure that have a good grasp. * Because 12 dots is about as simple as this is going to get! * * Changes from the script: * - Had to reverse Translate and Rotate. * - Had to use the Z axis of the calculated Vector as the X axis on the bitmap! * * But still encouraging - the principles and API are working, even if I still lack comprehension! */ for (int hour = 1; hour <= 12; hour++) { var rotation = hour * MathF.PI / 6; var builder = new MatrixTransformationBuilder(); builder.Translate(new Vector3(0F, 0F, 18.75F)) .RotateY(rotation); DrawProjectilePath(builder, canvas); } canvas.Save(outputBitmapFilePath); }