public RotateY(IHitable hitable, float angle) { Hitable = hitable; Angle = angle; float radians = MathF.PI / 180.0f * angle; SinTheta = MathF.Sin(radians); CosTheta = MathF.Cos(radians); var box = Hitable.GetBoundingBox(0.0f, 1.0f); var min = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue).ToSingleArray(); var max = new Vector3(-float.MaxValue, -float.MaxValue, -float.MaxValue).ToSingleArray(); for (int i = 0; i < 2; i++) { float dubi = Convert.ToSingle(i); for (int j = 0; j < 2; j++) { float dubj = Convert.ToSingle(j); for (int k = 0; k < 2; k++) { float dubk = Convert.ToSingle(k); float x = (dubi * box.Max.X) + ((1.0f - dubi) * box.Min.X); float y = (dubj * box.Max.Y) + ((1.0f - dubj) * box.Min.Y); float z = (dubk * box.Max.Z) + ((1.0f - dubk) * box.Min.Z); float newx = (CosTheta * x) + (SinTheta * z); float newz = (-SinTheta * x) + (CosTheta * z); var tester = new Vector3(newx, y, newz).ToSingleArray(); for (int c = 0; c < 3; c++) { if (tester[c] > max[c]) { max[c] = tester[c]; } if (tester[c] < min[c]) { min[c] = tester[c]; } } } } } BoundingBox = new AABB(new Vector3(min[0], min[1], min[2]), new Vector3(max[0], max[1], max[2])); }