/// <summary> /// Check for common pixels which are not transparent. /// </summary> /// <param name="i_Intersectable1">First IIntersectable object.</param> /// <param name="i_Intersectable2">Second IIntersectable object.</param> /// <param name="o_IntersectionPoints">All of the intersection points.</param> /// <returns>True if both objects intersecred, otherwise false.</returns> private bool pixelWiseIntersection(IIntersectable i_Intersectable1, IIntersectable i_Intersectable2, out List <Vector2> o_IntersectionPoints) { o_IntersectionPoints = new List <Vector2>(); bool isIntersected = false; if (i_Intersectable1.ShapeRectangle.Intersects(i_Intersectable2.ShapeRectangle)) { Rectangle intersectedRectangle = intersectionRectangle(i_Intersectable1, i_Intersectable2); Color[] sprite1Colors = i_Intersectable1.ObjectColors; Color[] sprite2Colors = i_Intersectable2.ObjectColors; for (int x = intersectedRectangle.Left; x <= intersectedRectangle.Right; x++) { for (int y = intersectedRectangle.Bottom - 1; y >= intersectedRectangle.Top; y--) { int sprite1_index = x - i_Intersectable1.ShapeRectangle.Left + ((y - i_Intersectable1.ShapeRectangle.Top) * i_Intersectable1.ShapeRectangle.Width); int sprite2_index = x - i_Intersectable2.ShapeRectangle.Left + ((y - i_Intersectable2.ShapeRectangle.Top) * i_Intersectable2.ShapeRectangle.Width); if ((sprite1_index < sprite1Colors.Length) && (sprite2_index < sprite2Colors.Length)) { Color currentPixelSprite1 = sprite1Colors[sprite1_index]; Color currentPixelSprite2 = sprite2Colors[sprite2_index]; if ((currentPixelSprite1 != sr_transparent) && (currentPixelSprite2 != sr_transparent)) { isIntersected = true; } o_IntersectionPoints.Add(new Vector2(x, y)); } } } } return(isIntersected); }
private static Cell[] GetSurroundingCells(this IIntersectable item, Cell[,] maze) { Rectangle aabb = item.GetAABB(); List <Cell> cells = new List <Cell>(); int currentCellX = aabb.Center.X / Tile.Size; int currentCellY = aabb.Center.Y / Tile.Size; int smallX = currentCellX - 1; int largeX = currentCellX + 1; int smallY = currentCellY - 1; int largeY = currentCellY + 1; for (int y = smallY; y <= largeY; y++) { for (int x = smallX; x <= largeX; x++) { Cell cell = maze[y, x]; if (cell.Tile.Id != 0) { cells.Add(cell); } } } return(cells.ToArray()); }
/// <summary> /// Creates a new <c>IntersectionFinder</c> for the specified line feature. /// Use this constructor when intersecting something that has already been added to /// the map model. This ensures that the line is not intersected with itself. /// </summary> /// <param name="line">The line feature to intersect.</param> /// <param name="wantEndEnd">Specify true if you want end-to-end intersections in the results.</param> internal IntersectionFinder(LineFeature line, bool wantEndEnd) { m_Line = line; ISpatialIndex index = CadastralMapModel.Current.Index; m_Intersects = new FindIntersectionsQuery(index, line, wantEndEnd).Result; }
public IIntersectable SatisfyRelations(Point?p = null) { IList <IIntersectable> possibles = new List <IIntersectable>(); foreach (Relation2D rel in this.Relations2D) { if (!rel.IsDriven(this)) { IIntersectable temp = rel.Satisfy(); possibles.Add(temp); } } switch (possibles.Count()) { case 0: return(p == null ? null : new Point2D(p.Value)); case 1: return(possibles[0]); default: for (int i = 1; i < possibles.Count; i++) { // TODO: Intersection of all possibles } return(null); } }
public static bool AabbAabbIntersectionTest(this IIntersectable A, IIntersectable B) { Rectangle a = A.GetAABB(); Rectangle b = B.GetAABB(); return(!(a.Right < b.Left || a.Left > b.Right || a.Bottom < b.Top || a.Top > b.Bottom)); }
private void CheckColumn(int[,] pts, IIntersectable sender, double u, int column, int from, int to, double vStep, double vFrom) { //pts[j, i] = PointBelongs(partA, sender, new Vector2(i * uStep + uFrom, j * vStep + vFrom)); if (pts[from, column] == -1) { pts[from, column] = PointBelongs(sender, new Vector2(u, from * vStep + vFrom)); } if (pts[to, column] == -1) { pts[to, column] = PointBelongs(sender, new Vector2(u, to * vStep + vFrom)); } if (from == to || from + 1 == to) { return; } if (pts[from, column] == pts[to, column]) { for (int i = from + 1; i < to; i++) { pts[i, column] = pts[from, column]; } } else { var newPt = (from + to) / 2; CheckColumn(pts, sender, u, column, from, newPt, vStep, vFrom); CheckColumn(pts, sender, u, column, newPt, to, vStep, vFrom); } }
public static bool SatIntersectionTest(this IIntersectable A, IIntersectable B) { if (A.GetSatProjectionAxes().Length == 0 || B.GetSatProjectionAxes().Length == 0) { return(false); } List <Vector2> axes = new List <Vector2>(); axes.AddRange(A.GetSatProjectionAxes()); axes.AddRange(B.GetSatProjectionAxes()); foreach (Vector2 axis in axes) { Range projectionA = A.Get1dProjectionOntoAxis(axis); Range projectionB = B.Get1dProjectionOntoAxis(axis); if (!IsThere1dProjectionOverlap(projectionA, projectionB)) { return(false); } } return(true); }
/// <summary> /// Constructor used to combine a series of <c>IntersectResult</c> objects. This /// implementation is used to obtain a results object for a new topological line /// that has just been intersected against the map. /// </summary> /// <param name="xsect">The result of intersecting a line with the map</param> internal IntersectionResult(IntersectionFinder xsect) { m_IntersectedObject = xsect.Intersector; m_Geom = m_IntersectedObject.LineGeometry; m_Data = null; // Get the total number of intersections that were found (there's one // InteresectionResult for each intersected line) IList<IntersectionResult> results = xsect.Intersections; int nData = 0; foreach (IntersectionResult r in results) nData += r.m_Data.Count; // Return if no intersections. if (nData==0) return; // Copy over the info m_Data = new List<IntersectionData>(nData); foreach (IntersectionResult r in results) { List<IntersectionData> data = r.Intersections; foreach (IntersectionData d in data) m_Data.Add(d); } // Reverse all context codes. foreach (IntersectionData d in m_Data) d.ReverseContext(); }
public Color Integrate(Ray ray, IIntersectable objects, List <ILight> lights, ISampler sampler, List <List <Sample> > subPathSamples, LightSample lightSample) { shadowIntegrator = new ShadowIntegrator(); Color returnColor = new Color(0, 0, 0); HitRecord record = objects.Intersect(ray); if (record != null) { if (!(record.Material is MirrorMaterial)) { returnColor.Append(shadowIntegrator.Integrate(ray, objects, lights, sampler, subPathSamples, lightSample)); } if (record.Material is MirrorMaterial && record.Material.Specular.R > 0 && record.Material.Specular.G > 0 && record.Material.Specular.B > 0) { returnColor.Append(Reflection(ray, record, 0, returnColor, objects, lights, sampler, subPathSamples, lightSample)); } } else { if (SkyBox.IsSkyBoxLoaded()) { returnColor = SkyBox.GetSkyBoxColor(ray); } } return(returnColor); }
/// <summary> /// Intersect a ray with scene objects. Writes out hit data. /// </summary> /// <param name="ray">The ray that will be intersected with the scene.</param> /// <param name="hitData">The hit data of the closest hit that will be written out if there is an intersection. /// Will output HitData.NoHit otherwise and can be checked with the exists() method on the object.</param> /// <returns>Returns true, if there is an intersection with at least one scene object, false otherwise.</returns> public bool Intersect(Ray ray, out HitData hitData, bool isShadowRay = false) { // TODO: Use acceleration Data structures HitData closestHit = HitData.NoHit; HitData lastHit; ObjectList.ForEach((IIntersectable) => { if (isShadowRay && IIntersectable.CastShadows == false) { return; } if (IIntersectable.Intersect(ray, out lastHit)) { if (!closestHit.exists() && lastHit.exists()) { closestHit = lastHit; return; } if (ray.Start.Distance(lastHit.Position) < ray.Start.Distance(closestHit.Position)) { closestHit = lastHit; } } }); hitData = closestHit; return(hitData.exists()); }
public Color Integrate(Ray ray, IIntersectable objects, List <ILight> lights, ISampler sampler, List <List <Sample> > subPathSamples, LightSample lightSample) { HitRecord record = objects.Intersect(ray); Color returnColor = new Color(0, 0, 0); if (record != null) { foreach (ILight light in lights) { Vector3 lightDirection = light.GetLightDirection(record.IntersectionPoint); Vector3 hitPos = record.IntersectionPoint; Vector3 offset = record.RayDirection; offset = -offset; offset *= 0.001f; hitPos += offset; Ray shadowRay = new Ray(hitPos, lightDirection); HitRecord shadowHit = objects.Intersect(shadowRay); Vector3 distance = Vector3.Subtract(light.Position, hitPos); //DEBUGGING /*if (shadowHit != null && (shadowHit.Distance > distance.Length)) * { * returnColor.Append(record.HitObject.Material.Shade(record, light.GetLightDirection(record.IntersectionPoint)).Mult(light.GetIncidentColor(record.IntersectionPoint))); * }*/ returnColor.Append(record.HitObject.Material.Shade(record, light.GetLightDirection(record.IntersectionPoint)).Mult(light.GetIncidentColor(record.IntersectionPoint))); } } return(returnColor); }
public AreaLight(Color c, IIntersectable shape) { Shape = shape; LightColor = c; shape.Light = this; Pdf = (1f / Shape.GetArea()); }
public bool Intersect(Ray ray, out HitData hitData) { // Outsource this into the scene to enable accelerating data structures. Ray offsettedRay = new Ray(ray.Start - Position, ray.Direction); HitData closestHit = HitData.NoHit; HitData lastHit; triangles.ForEach((IIntersectable) => { if (IIntersectable.Intersect(offsettedRay, out lastHit)) { HitData offsettedHit = new HitData(lastHit.Position + Position, lastHit.Normal, lastHit.TextureCoords, lastHit.Material); if (!closestHit.exists() && lastHit.exists()) { closestHit = offsettedHit; return; } if (offsettedRay.Start.Distance(offsettedHit.Position) < offsettedRay.Start.Distance(closestHit.Position)) { closestHit = offsettedHit; } } }); hitData = closestHit; return(hitData.exists()); }
/// <summary> /// Creates a new <c>IntersectionFinder</c> for the specified geometry. /// Use this constructor when intersecting geometry that has been created ad-hoc. /// </summary> /// <param name="geom">The geometry to intersect.</param> /// <param name="wantEndEnd">Specify true if you want end-to-end intersections in the results.</param> internal IntersectionFinder(LineGeometry geom, bool wantEndEnd) { m_Line = geom; ISpatialIndex index = CadastralMapModel.Current.Index; m_Intersects = new FindIntersectionsQuery(index, geom, wantEndEnd).Result; }
public int PointBelongs(IIntersectable sender, Vector2 point) { counter++; int p = boundary?.Count(tuple => IntersectLines(tuple.Item1, tuple.Item2, point)) ?? 0; Vector2 p1, p2; int cnt = poly.Count - 1; var minSize = System.Math.Min(sender.FirstParamLimit, sender.SecondParamLimit) * 0.8; for (int i = 0; i < cnt; i++) { p1 = poly[i]; p2 = poly[i + 1]; if ((p1 - p2).Length() < minSize) { if (IntersectLines(p1, p2, point)) { p++; } } } if (cyclic) { if ((poly[cnt] - poly[0]).Length() < minSize) { if (IntersectLines(poly[cnt], poly[0], point)) { p++; } } } return(p); }
/// <summary> /// Rectangle boundries for available pixels that can be intersected. /// </summary> /// <param name="i_Intersectable1">First IIntersectable object.</param> /// <param name="i_Intersectable2">Second IIntersectable object.</param> /// <returns>A rectangle for available pixels that can be intersected.</returns> private Rectangle intersectionRectangle(IIntersectable i_Intersectable1, IIntersectable i_Intersectable2) { int max_x = MathHelper.Min(i_Intersectable1.ShapeRectangle.Right, i_Intersectable2.ShapeRectangle.Right); int min_x = MathHelper.Max(i_Intersectable1.ShapeRectangle.Left, i_Intersectable2.ShapeRectangle.Left); int max_y = MathHelper.Min(i_Intersectable1.ShapeRectangle.Bottom, i_Intersectable2.ShapeRectangle.Bottom); int min_y = MathHelper.Max(i_Intersectable1.ShapeRectangle.Top, i_Intersectable2.ShapeRectangle.Top); return(new Rectangle(min_x, min_y, max_x - min_x, max_y - min_y)); }
public Instance(IIntersectable intersectable, Matrix4 transMatrix) { TransformationMatrix = transMatrix; Intersectable = intersectable; InvTransformationMatrix = Matrix4.Invert(TransformationMatrix); TransposedTransformationMatrix = Matrix4.Transpose(InvTransformationMatrix); Material = Intersectable.Material; Add(intersectable); }
public HitRecord(float t, Vector3 hitPoint, Vector3 normal, IIntersectable hitObject, Material material, Vector3 rayDirection) { Distance = t; IntersectionPoint = hitPoint; SurfaceNormal = normal; HitObject = hitObject; Material = material; RayDirection = rayDirection; InvRayDirection = new Vector3(1 / RayDirection.X, 1 / RayDirection.Y, 1 / RayDirection.Z); }
public IIntersectable SatisfyRelations(Point?p = null) { IIntersectable e = this; foreach (Relation2D rel in this.Relations2D) { rel.Satisfy(); } return(null); }
public Color Integrate(Ray ray, IIntersectable objects, List <ILight> lights, ISampler sampler, List <List <Sample> > subPathSamples, LightSample lightSample) { HitRecord record = objects.Intersect(ray); Color retColor = new Color(0, 0, 0); this.objects = objects; this.lights = lights; this.sampler = sampler; retColor.Append(GetShadeColor(record, 0)); return(retColor); }
public static void SpawnInAnEmptyPosition(this ISpawnable itemToSpawn, Cell[,] maze) { IIntersectable intersectable = (IIntersectable)itemToSpawn; do { itemToSpawn.SetPosition( rng.Next(2 * Tile.Size, (maze.GetLength(1) - 1) * Tile.Size), rng.Next(2 * Tile.Size, (maze.GetLength(0) - 1) * Tile.Size)); } while (intersectable.AabbMapIntersectionTest(maze)); }
/// <summary> /// This hurtable sprite got hurt by some Intersectable. /// </summary> /// <param name="i_Intersectable">The Intersectable that intersects this sprite.</param> /// /// <param name="i_IntersectionPoints">Intersection points.</param> public void GotHurt(IIntersectable i_Intersectable, List <Vector2> i_IntersectionPoints = null) { if (i_Intersectable is IAttacker) { attacked(i_Intersectable as IAttacker); } else if (i_IntersectionPoints != null) { touched(i_IntersectionPoints); } }
public bool IsIntersectable(IIntersectable sender) { if (sender == P) { return(IsIntersectableP); } if (sender == Q) { return(IsIntersectableQ); } return(false); }
public static IList<Point> GetIntersections(IIntersectable e1, IIntersectable e2) { //todo Preco sa nemozu volat rovnako GetIntersections a GetIntersects?? dynamic o1 = e1; dynamic o2 = e2; try { return GetIntersects(o1, o2); } catch(Exception e) { return GetIntersects(o2, o1); } }
public static IList <Point> GetIntersections(IIntersectable e1, IIntersectable e2) { //todo Preco sa nemozu volat rovnako GetIntersections a GetIntersects?? dynamic o1 = e1; dynamic o2 = e2; try { return(GetIntersects(o1, o2)); } catch (Exception e) { return(GetIntersects(o2, o1)); } }
public Color Integrate(Ray ray, IIntersectable objects, List <ILight> lights, ISampler sampler, List <List <Sample> > subPathSamples, LightSample lightSample) { HitRecord record = objects.Intersect(ray); if (record != null) { return(new Color(1, 1, 1)); } else { return(new Color(0, 0, 0)); } }
public BvhNode(IIntersectable left, IIntersectable right) { _left = left; _right = right; if (left != null) { _leftBounds = left.GetBoundingBox(); } if (right != null) { _rightBounds = right.GetBoundingBox(); } }
public Relation2D(params Point2D[] points) { var point = points.Last(); if (point == null) { throw new Exceptions.InvalidSetRelationException(); } points.ToList <Point2D>().ForEach((p) => { Relatables.Add(p); }); IIntersectable previousRelations = point.SatisfyRelations(); IIntersectable i = Satisfy(); if (i == null) { throw new Exceptions.InvalidSetRelationException(); } IList <Point> intersect = previousRelations != null?previousRelations.Intersection(i) : null; if (previousRelations == null || intersect.Count() > 0) { Point?p; if (previousRelations == null) { p = i.GetNearest(point.Point); } else { p = intersect.GetNearest(point.Point); } point.Point = p != null ? p.Value : point.Point; foreach (Point2D pt in points) { if (!pt.Relations2D.Contains(this)) { pt.Relations2D.Add(this); } } } else { throw new Exceptions.ConflictRelationException(); } }
public static bool AabbMapIntersectionTest(this IIntersectable item, Cell[,] maze) { foreach (Cell cell in item.GetSurroundingCells(maze)) { if (item.AabbAabbIntersectionTest(cell)) { if (item.SatIntersectionTest(cell)) { return(true); } } } return(false); }
public Color Integrate(Ray ray, IIntersectable objects, List <ILight> lights, ISampler sampler, List <List <Sample> > subPathSamples, LightSample lightSample) { Color returnColor = new Color(0, 0, 0); /* * Core Ray Tracing algorithm */ HitRecord record = objects.Intersect(ray); if (record != null && record.Distance > 0 && record.Distance < float.PositiveInfinity) { foreach (ILight light in lights) { returnColor.Append(record.Material.Shade(record, light.GetLightDirection(record.IntersectionPoint)).Mult(light.GetIncidentColor(record.IntersectionPoint))); } } return(returnColor); }
/// <summary> /// Checks if this instance of IIntersectable contains the provided IIntersectable instance /// </summary> /// <param name="other">IIntersectable object to check contention with</param> /// <returns>true if the IIntersectable object provided is completely contained within, false otherwise</returns> public virtual bool Contains(IIntersectable other) { throw new NotImplementedException(); //Vector3[] vertexes = new Vector3[] //{ // // Front // // Upper right // // Upper left // // Lower left // // Lower right // // Back // // Upper right // // Upper left // // Lower left // // Lower right //}; }
private void IntersectSurfaces() { List <Vector4> intersection = null; IIntersectable first = null; IIntersectable second = null; bool cyclic = false; try { var selected = models.Where(x => x.IsSelected).ToList(); var sel = selected.Select(x => x as IIntersectable).Distinct().ToList(); if (sel.Count == 2) { first = sel[0]; second = sel[1]; if (first != null && second != null) { intersection = Intersection.Intersect(sel[0], sel[1], this, NewtonStep, out cyclic); } } } catch (Exception e) { intersection = null; } if (intersection != null && intersection.Count > 2) { //intersection.ForEach(x => CreateHiddenCatPoint(sel[0].GetPosition(x.X, x.Y))); var curv = new GeometryModels.CuttingCurve(intersection, first, second, this, cyclic, CuttingCurveApproximation); AddNewModel(curv); first.SetCuttingCurve(curv); second.SetCuttingCurve(curv); } else { var sampleMessageDialog = new MessageHost { Message = { Text = "Proper intersection could not be found." } }; DialogHost.Show(sampleMessageDialog, "RootDialog"); } }
public virtual IList<Point> Intersection(IIntersectable shape) { return Helpers.AnalyticGeometryHelper.GetIntersections(this, shape); }
public Renderable(IIntersectable geometry, IMaterial material) { Geometry = geometry; Material = material; }
/// <summary> /// Checks if this instance of Ray intersects with another /// </summary> /// <param name="other">IIntersectable object to check intersection with</param> /// <returns>true if there is intersection, false otherwise</returns> public bool Intersects(IIntersectable other) { throw new Exception("The method or operation is not implemented."); }
/// <summary> /// Creates a new <c>IntersectionResult</c> for the specified line. This /// implementation is used when intersecting ad-hoc geometry, as well as /// representing the results of intersecting a line feature with previously /// existing topology. /// </summary> /// <param name="intersectedObject"></param> internal IntersectionResult(IIntersectable intersectedObject) { m_IntersectedObject = intersectedObject; m_Geom = intersectedObject.LineGeometry; m_Data = new List<IntersectionData>(); }
/// <summary> /// Default constructor. /// </summary> IntersectionFinder() { m_Line = null; m_Intersects = new List<IntersectionResult>(); }
public IList<Point> Intersection(IIntersectable shape) { return shape.Intersection(this); }
/// <summary> /// Checks if this instance of IIntersectable intersects with another /// </summary> /// <param name="other">IIntersectable object to check intersection with</param> /// <returns>true if there is intersection, false otherwise</returns> public virtual bool Intersects(IIntersectable other) { throw new NotImplementedException(); //// float ra, rb; //// Matrix33 R, AbsR; //int i, j; //// Compute rotation matrix expressing b in a's coordinate frame //for (i = 0; i < 3; i++) //{ // for (j = 0; j < 3; j++) ; // //R[i][j] = Dot(a.u[i], b.u[j]); //} // /* int TestOBBOBB(OBB &a, OBB &b) { // Compute translation vector t Vector t = b.c - a.c; // Bring translation into a’s coordinate frame t = Vector(Dot(t, a.u[0]), Dot(t, a.u[2]), Dot(t, a.u[2])); // Compute common subexpressions. Add in an epsilon term to // counteract arithmetic errors when two edges are parallel and // their cross product is (near) null (see text for details) for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) AbsR[i][j] = Abs(R[i][j]) + EPSILON; // Test axes L = A0, L = A1, L = A2 for (int i = 0; i < 3; i++) { ra = a.e[i]; rb = b.e[0] * AbsR[i][0] + b.e[1] * AbsR[i][1] + b.e[2] * AbsR[i][2]; if (Abs(t[i]) > ra + rb) return 0; } // Test axes L = B0, L = B1, L = B2 for (int i = 0; i < 3; i++) { ra = a.e[0] * AbsR[0][i] + a.e[1] * AbsR[1][i] + a.e[2] * AbsR[2][i]; rb = b.e[i]; if (Abs(t[0] * R[0][i] + t[1] * R[1][i] + t[2] * R[2][i]) > ra + rb) return 0; } // Test axis L = A0 x B0 ra = a.e[1] * AbsR[2][0] + a.e[2] * AbsR[1][0]; rb = b.e[1] * AbsR[0][2] + b.e[2] * AbsR[0][1]; if (Abs(t[2] * R[1][0] - t[1] * R[2][0]) > ra + rb) return 0; // Test axis L = A0 x B1 ra = a.e[1] * AbsR[2][1] + a.e[2] * AbsR[1][1]; rb = b.e[0] * AbsR[0][2] + b.e[2] * AbsR[0][0]; if (Abs(t[2] * R[1][1] - t[1] * R[2][1]) > ra + rb) return 0; // Test axis L = A0 x B2 ra = a.e[1] * AbsR[2][2] + a.e[2] * AbsR[1][2]; rb = b.e[0] * AbsR[0][1] + b.e[1] * AbsR[0][0]; if (Abs(t[2] * R[1][2] - t[1] * R[2][2]) > ra + rb) return 0; // Test axis L = A1 x B0 ra = a.e[0] * AbsR[2][0] + a.e[2] * AbsR[0][0]; rb = b.e[1] * AbsR[1][2] + b.e[2] * AbsR[1][1]; if (Abs(t[0] * R[2][0] - t[2] * R[0][0]) > ra + rb) return 0; // Test axis L = A1 x B1 ra = a.e[0] * AbsR[2][1] + a.e[2] * AbsR[0][1]; rb = b.e[0] * AbsR[1][2] + b.e[2] * AbsR[1][0]; if (Abs(t[0] * R[2][1] - t[2] * R[0][1]) > ra + rb) return 0; // Test axis L = A1 x B2 ra = a.e[0] * AbsR[2][2] + a.e[2] * AbsR[0][2]; rb = b.e[0] * AbsR[1][1] + b.e[1] * AbsR[1][0]; if (Abs(t[0] * R[2][2] - t[2] * R[0][2]) > ra + rb) return 0; // Test axis L = A2 x B0 ra = a.e[0] * AbsR[1][0] + a.e[1] * AbsR[0][0]; rb = b.e[1] * AbsR[2][2] + b.e[2] * AbsR[2][1]; if (Abs(t[1] * R[0][0] - t[0] * R[1][0]) > ra + rb) return 0; // Test axis L = A2 x B1 ra = a.e[0] * AbsR[1][1] + a.e[1] * AbsR[0][1]; rb = b.e[0] * AbsR[2][2] + b.e[2] * AbsR[2][0]; if (Abs(t[1] * R[0][1] - t[0] * R[1][1]) > ra + rb) return 0; // Test axis L = A2 x B2 ra = a.e[0] * AbsR[1][2] + a.e[1] * AbsR[0][2]; rb = b.e[0] * AbsR[2][1] + b.e[1] * AbsR[2][0]; if (Abs(t[1] * R[0][2] - t[0] * R[1][2]) > ra + rb) return 0; // Since no separating axis is found, the OBBs must be intersecting return 1; } */ }
public void AddGeometry(IIntersectable geometry) { Ensure.That("geometry", geometry).IsNotNull(); _geometry.Add(geometry); }
public Color DetermineRayColor(Ray ray, IIntersectable scene) { var intersection = scene.FindClosestIntersectionWith(ray); return intersection == null ? Color.Black : intersection.Color; }