public RotateZ(GeometryObject p, double angle) { ptr = p; double radians = (Math.PI / 180.0) * angle; sinTheta = Math.Sin(radians); cosTheta = Math.Cos(radians); hasBox = ptr.bounding_box(0, 1, out bbox); Point3D min = new Point3D(1e30, 1e30, 1e30); Point3D max = new Point3D(-1e30, -1e30, -1e30); for (int i = 0; i < 2; ++i) { for (int j = 0; j < 2; ++j) { for (int k = 0; k < 2; ++k) { double x = i * bbox.Max.X + (1 - i) * bbox.Min.X; double y = j * bbox.Max.Y + (1 - j) * bbox.Min.Y; double z = k * bbox.Max.Z + (1 - k) * bbox.Min.Z; double newX = cosTheta * x + sinTheta * y; double newY = -sinTheta * x + cosTheta * y; Point3D tster = new Point3D(newX, newY, z); if (tster.X > max.X) { max.X = tster.X; } if (tster.X < min.X) { min.X = tster.X; } if (tster.Y > max.Y) { max.Y = tster.Y; } if (tster.Y < min.Y) { min.Y = tster.Y; } if (tster.Z > max.Z) { max.Z = tster.Z; } if (tster.Z < min.Z) { min.Z = tster.Z; } } } } bbox = new aabb(min, max); }
public Box(Point3D _pmin, Point3D _pmax, GeoMaterial ptr) { pmin = _pmin; pmax = _pmax; List <GeometryObject> list = new List <GeometryObject>(); list.Add(new XYRect(pmin.X, pmax.X, pmin.Y, pmax.Y, pmax.Z, ptr)); list.Add(new FilpNormals(new XYRect(pmin.X, pmax.X, pmin.Y, pmax.Y, pmin.Z, ptr))); list.Add(new XZRect(pmin.X, pmax.X, pmin.Z, pmax.Z, pmax.Y, ptr)); list.Add(new FilpNormals(new XZRect(pmin.X, pmax.X, pmin.Z, pmax.Z, pmin.Y, ptr))); list.Add(new YZRect(pmin.Y, pmax.Y, pmin.Z, pmax.Z, pmax.X, ptr)); list.Add(new FilpNormals(new YZRect(pmin.Y, pmax.Y, pmin.Z, pmax.Z, pmin.X, ptr))); list_ptr = new GlobalGeometryList(list); }
public bvh_node(List <GeometryObject> l) { int axis = (int)(3 * Form2.random()); if (axis == 0) { l.Sort(new Cmp_x().Compare); } else if (axis == 1) { l.Sort(new Cmp_y().Compare); } else { l.Sort(new Cmp_z().Compare); } int n = l.Count(); if (n == 1) { left = right = l[0]; } else if (n == 2) { left = l[0]; right = l[1]; } else { List <GeometryObject> left_l = new List <GeometryObject>(), right_l = new List <GeometryObject>(); for (int i = 0; i < n / 2; ++i) { left_l.Add(l[i]); } for (int i = n / 2; i < n; ++i) { right_l.Add(l[i]); } left = new bvh_node(left_l); right = new bvh_node(right_l); } aabb box_left = null, box_right = null; if (!left.bounding_box(0, 1, out box_left) || !right.bounding_box(0, 1, out box_right)) { Console.WriteLine("no bounding box!"); } _box = aabb.surrounding_box(box_left, box_right); }
public FilpNormals(GeometryObject _obj) { obj = _obj; }
public Translate(GeometryObject p, Vector3D displacement) { ptr = p; offset = displacement; }
public void AddGeoObj(GeometryObject geometryObject) { geometrys.Add(geometryObject); }
public ConstantMedium(GeometryObject obj, double _density, Texture texture) { boundary = obj; density = _density; phase_function = new Isotropic(texture); }