public void Set(Plane3 c) { Math3D.Set(normal, c.normal); dist = c.dist; type = c.type; signbits = c.signbits; pad[0] = c.pad[0]; pad[1] = c.pad[1]; }
/// <summary> /// Sets the specified c. /// </summary> /// <param name="c">The c.</param> public void Set(Plane3 c) { Math3D.Set(normal, c.normal); Distance = c.Distance; Type = c.Type; Signbits = c.Signbits; Pad[0] = c.Pad[0]; Pad[1] = c.Pad[1]; }
public void UpdatePlanes() { mathPlane0 = CreatePlane3(Plane0); mathPlane1 = CreatePlane3(Plane1); boxedPlane0.UpdatePlane(mathPlane0); boxedPlane1.UpdatePlane(mathPlane1); test = Intersection.TestPlane3Plane3(ref mathPlane0, ref mathPlane1); find = Intersection.FindPlane3Plane3(ref mathPlane0, ref mathPlane1, out info); DrawResult(); }
public void RandomizePlanes() { Vector3 n0 = Randomize(), n1 = Randomize(); LogInfo("Normal n0: " + n0.ToString()); LogInfo("Normal n1: " + n1.ToString()); mathPlane0 = boxedPlane0.Setup(n0); mathPlane1 = boxedPlane1.Setup(n1); BoxedPlane.UpdateTransformPlane(Plane0, mathPlane0); BoxedPlane.UpdateTransformPlane(Plane1, mathPlane1); UpdatePlanes(); }
private void OnDrawGizmos() { Plane3 plane = CreatePlane3(Plane); Box3 box = CreateBox3(Box); bool test = Intersection.TestPlane3Box3(ref plane, ref box); FiguresColor(); DrawPlane(ref plane, Plane); DrawBox(ref box); LogInfo("Intersection: " + test); }
private void OnDrawGizmos() { Plane3 plane = CreatePlane3(Plane); AAB3 box = CreateAAB3(Box_Point0, Box_Point1); bool test = Intersection.TestPlane3AAB3(ref plane, ref box); FiguresColor(); DrawPlane(ref plane, Plane); DrawAAB(ref box); LogInfo("Intersection: " + test); }
private void OnDrawGizmos() { Vector3[] points = CreatePoints3(Points); if (points.Length > 1) { Plane3 plane = Approximation.LeastSquaresPlaneFit3(points); FiguresColor(); DrawPoints(points); ResultsColor(); DrawPlane(ref plane, Points[0]); } }
private void OnDrawGizmos() { Plane3 plane = CreatePlane3(Plane); Polygon3 polygon = new Polygon3(Points.Length, plane); for (int i = 0; i < Points.Length; ++i) { polygon.SetVertexProjected(i, Points[i].position); } polygon.UpdateEdges(); DrawPolygon(polygon); }
public IEnumerable <Object> FetchDependencies(ISerializedFile file, bool isLog = false) { yield return(Plane0.FetchDependency(file, isLog, () => nameof(CollisionModule), "m_Plane0")); yield return(Plane1.FetchDependency(file, isLog, () => nameof(CollisionModule), "m_Plane1")); yield return(Plane2.FetchDependency(file, isLog, () => nameof(CollisionModule), "m_Plane2")); yield return(Plane3.FetchDependency(file, isLog, () => nameof(CollisionModule), "m_Plane3")); yield return(Plane4.FetchDependency(file, isLog, () => nameof(CollisionModule), "m_Plane4")); yield return(Plane5.FetchDependency(file, isLog, () => nameof(CollisionModule), "m_Plane5")); }
void Update() { time1 += Time.deltaTime; time2 += Time.deltaTime; time3 += Time.deltaTime; if (time1 > 7.0f) { if (Plane1.activeSelf == false) { Plane1.SetActive(true); time1 = 0; } else { Plane1.SetActive(false); time1 = 0; } } if (time2 > 7.0f) { if (Plane2.activeSelf == false) { Plane2.SetActive(true); time2 = 0; } else { Plane2.SetActive(false); time2 = 0; } } if (time3 > 7.0f) { if (Plane3.activeSelf == false) { Plane3.SetActive(true); time3 = 0; } else { Plane3.SetActive(false); time3 = 0; } } }
protected void DrawPlane(ref Plane3 plane, Transform Plane) { Vector3 u, v, n; plane.CreateOrthonormalBasis(out u, out v, out n); Matrix4x4 m = new Matrix4x4(); m.SetColumn(0, u); m.SetColumn(1, n); m.SetColumn(2, v); m.SetColumn(3, Plane.position); m.m33 = 1f; Gizmos.matrix = m; Gizmos.DrawCube(Vector3.zero, new Vector3(10, 0, 10)); Gizmos.matrix = Matrix4x4.identity; }
public Camera(Vector3 pos, Vector3 lookAt, Vector2 frustrumSize) { this.pos = pos; var dir = lookAt.Sub(ref pos); frustrumFrontPlane.topLeft.x = -frustrumSize.x / 2; frustrumFrontPlane.topLeft.y = frustrumSize.y / 2; frustrumFrontPlane.bottomRight.x = frustrumSize.x / 2; frustrumFrontPlane.bottomRight.y = -frustrumSize.y / 2; this.frustrumFrontPlane = new Plane3( topLeft: new Vector3(-frustrumSize.x / 2, frustrumSize.y / 2, 0), topRight: new Vector3(frustrumSize.x / 2, frustrumSize.y / 2, 0), bottomLeft: new Vector3(-frustrumSize.x / 2, -frustrumSize.y / 2, 0), bottomRight: new Vector3(frustrumSize.x / 2, -frustrumSize.y / 2, 0)); }
private void OnDrawGizmos() { Vector3 point = Point.position; Plane3 plane = CreatePlane3(Plane); Vector3 closestPoint; float dist0 = Distance.Point3Plane3(ref point, ref plane, out closestPoint); float dist1 = plane.DistanceTo(point); FiguresColor(); DrawPlane(ref plane, Plane); ResultsColor(); DrawPoint(closestPoint); LogInfo(dist0 + " " + dist1); }
// Token: 0x06000015 RID: 21 RVA: 0x00002CB4 File Offset: 0x00000EB4 private static void CreateTesselatedEdgePolyLine(List <Vector3> vertices, List <int[]> wires, IList <Vector3> sweepContour, ref AffineTransform3 transform, EdgePolyLineSegment3 edgePolyLine) { UnitVector3 unitVector = transform.AxisZ; Vector3 vector = (Vector3)transform.AxisX; IList <Vector3> vertices2 = edgePolyLine.Vertices; for (int i = 0; i < vertices2.Count - 2; i++) { Vector3 right = vertices2[i + 0]; Vector3 vector2 = vertices2[i + 1]; Vector3 left = vertices2[i + 2]; Vector3 vector3 = vector2 - right; Vector3 vector4 = left - vector2; UnitVector3 unitVector2; UnitVector3 unitVector3; if (vector3.TryGetNormalized(out unitVector2) && vector4.TryGetNormalized(out unitVector3)) { unitVector = unitVector3; UnitVector3 planeNormal; if (((Vector3)unitVector2 + (Vector3)unitVector3).TryGetNormalized(out planeNormal)) { Plane3 plane = new Plane3(planeNormal, vector2); SweptDiskSolidExtensions.ProjectToPlane(vertices, sweepContour.Count, unitVector2, plane); SweptDiskSolidExtensions.BuildWires(vertices, wires, sweepContour.Count); double scalar = plane.Normal.Dot(vector); vector -= plane.Normal * scalar; } } } UnitVector3 unitVector4 = unitVector; UnitVector3 axisY; UnitVector3 axisX; if (unitVector4.TryGetUnitCross(vector, out axisY) && axisY.TryGetUnitCross(unitVector4, out axisX)) { IList <Vector3> list = vertices2; Vector3 origin = list[list.Count - 1]; transform = new AffineTransform3(axisX, axisY, unitVector4, origin); SweptDiskSolidExtensions.CreateTransformedSweep(vertices, sweepContour, transform); SweptDiskSolidExtensions.BuildWires(vertices, wires, sweepContour.Count); } }
private void OnDrawGizmos() { Plane3 plane = CreatePlane3(Plane); Vector3 point = Point.position; AAB3 aab = CreateAAB3(AABMin, AABMax); Box3 box = CreateBox3(Box); Sphere3 sphere = CreateSphere3(Sphere); // Get side information. // -1 - on the negative side of the plane // 0 - on the plane or intersecting the plane // +1 - on the positive side of the plane int pointSide = plane.QuerySide(point); int aabSide = plane.QuerySide(ref aab); int boxSide = plane.QuerySide(ref box); int sphereSide = plane.QuerySide(ref sphere); // true when an object is on the positive side of the plane bool pointPos = plane.QuerySidePositive(point); bool aabPos = plane.QuerySidePositive(ref aab); bool boxPos = plane.QuerySidePositive(ref box); bool spherePos = plane.QuerySidePositive(ref sphere); // true when an object is on the negative side of the plane bool pointNeg = plane.QuerySideNegative(point); bool aabNeg = plane.QuerySideNegative(ref aab); bool boxNeg = plane.QuerySideNegative(ref box); bool sphereNeg = plane.QuerySideNegative(ref sphere); // Note that positive/negative tests are little bit more optimized than just query, // as they don't have separate check for 0 case. FiguresColor(); DrawPlane(ref plane, Plane); SetColor(pointSide); DrawPoint(point); SetColor(aabSide); DrawAAB(ref aab); SetColor(boxSide); DrawBox(ref box); SetColor(sphereSide); DrawSphere(ref sphere); LogInfo("PointSignedDistance: " + plane.SignedDistanceTo(point) + " PointNeg: " + pointNeg + " PointPos: " + pointPos + " AABNeg: " + aabNeg + " AABPos: " + aabPos + " BoxNeg: " + boxNeg + " BoxPos: " + boxPos + " SphereNeg: " + sphereNeg + " SpherePos: " + spherePos); }
public Plane3 this[int index] { get { switch (index) { case 0: return(Left); case 1: return(Right); case 2: return(Bottom); case 3: return(Top); case 4: return(Near); case 5: return(Far); default: throw new ArgumentOutOfRangeException(); } } set { switch (index) { case 0: Left = value; break; case 1: Right = value; break; case 2: Bottom = value; break; case 3: Top = value; break; case 4: Near = value; break; case 5: Far = value; break; default: throw new ArgumentOutOfRangeException(); } } }
/// <summary> /// Returns information about an intersection between a ray and a plane /// </summary> public static Line3Intersection GetRayIntersection( Ray3 ray, Plane3 plane ) { float startDot = plane.Normal.Dot( ray.Origin ); float diffDot = plane.Normal.Dot( ray.Direction ); if ( !Utils.CloseToZero( diffDot ) ) { float t = ( startDot + plane.Distance ) / -diffDot; if ( t >= 0 ) { Line3Intersection result = new Line3Intersection( ); result.IntersectedObject = plane; result.IntersectionPosition = ray.Origin + ( ray.Direction * t ); result.IntersectionNormal = plane.Normal; result.Distance = t; return result; } } return null; }
protected void DrawPlane(ref Plane3 plane, Transform Plane) { Vector3 u, v, n; plane.CreateOrthonormalBasis(out u, out v, out n); Matrix4x4 m = new Matrix4x4(); m.SetColumn(0, u); m.SetColumn(1, n); m.SetColumn(2, v); m.SetColumn(3, Plane.position); m.m33 = 1f; Gizmos.matrix = m; Gizmos.DrawCube(Vector3.zero, new Vector3(10, 0, 10)); Gizmos.matrix = Matrix4x4.identity; /* * GameObject planeObject = Resources.Load("Plane") as GameObject; * planeObject = Instantiate(planeObject); * planeObject.transform.position = Plane.position; * planeObject.transform.Rotate(Plane.eulerAngles);*/ }
private void OnDrawGizmos() { Plane3 plane = CreatePlane3(Plane); Triangle3 triangle = CreateTriangle3(V0, V1, V2); bool test = Intersection.TestPlane3Triangle3(ref plane, ref triangle); Plane3Triangle3Intr info; bool find = Intersection.FindPlane3Triangle3(ref plane, ref triangle, out info); FiguresColor(); DrawPlane(ref plane, Plane); DrawTriangle(ref triangle); if (find) { ResultsColor(); if (info.Quantity == 2) { DrawSegment(info.Point0, info.Point1); } } LogInfo("test: " + test + " find: " + info.IntersectionType); }
private void OnDrawGizmos() { Plane3 plane0 = CreatePlane3(Plane0); Plane3 plane1 = CreatePlane3(Plane1); bool test = Intersection.TestPlane3Plane3(ref plane0, ref plane1); Plane3Plane3Intr info; bool find = Intersection.FindPlane3Plane3(ref plane0, ref plane1, out info); FiguresColor(); DrawPlane(ref plane0, Plane0); DrawPlane(ref plane1, Plane1); if (find) { if (info.IntersectionType == IntersectionTypes.Line) { ResultsColor(); DrawLine(ref info.Line); } } LogInfo("test: " + test + " find: " + info.IntersectionType); }
public void TestBoundingBoxCalculationForYPlane() { Plane3 yPlane = new Plane3(Vector3.UnitY * 2.0f, Vector3.Up); Assert.AreEqual( new Volumes.AxisAlignedBox3( new Vector3(float.NegativeInfinity, 2.0f, float.NegativeInfinity), new Vector3(float.PositiveInfinity, 2.0f, float.PositiveInfinity) ), yPlane.BoundingBox ); }
public void TestRandomPointOnPerimeterForYPlane() { IRandom randomNumberGenerator = new DefaultRandom(); Plane3 yPlane = new Plane3(Vector3.UnitY * 2.0f, Vector3.Up); for(int index = 0; index < Specifications.ProbabilisticFunctionSamples; ++index) { Vector3 randomPoint = yPlane.RandomPointOnPerimeter(randomNumberGenerator); Assert.IsTrue(float.IsInfinity(randomPoint.X)); Assert.AreEqual(2.0f, randomPoint.Y); Assert.IsTrue(float.IsInfinity(randomPoint.Z)); } }
/// <summary>Determines where the range clips a plane</summary> /// <param name="plane">Plane that will be checked for intersection</param> /// <returns>The times at which the range touches the plane, if at all</returns> public LineContacts FindContacts(Plane3 plane) { LineContacts contacts = Collisions.Line3Plane3Collider.FindContacts( Origin, Direction, plane.Offset, plane.Normal ); limitContactToRay(ref contacts); return contacts; }
public void TestThrowOnRandomPointOnPerimeterWithBrokenRandom() { IRandom randomNumberGenerator = new BrokenRandom(); Plane3 plane = new Plane3(Vector3.Zero, Vector3.Normalize(Vector3.One)); Assert.Throws<InvalidOperationException>( delegate() { plane.RandomPointOnPerimeter(randomNumberGenerator); } ); }
public void TestCenterOfMass() { Plane3 zeroPlane = new Plane3(Vector3.Zero, Vector3.Up); Assert.AreEqual(Vector3.Zero, zeroPlane.CenterOfMass); Plane3 xPlane = new Plane3(Vector3.UnitX, Vector3.Right); Assert.AreEqual(Vector3.Right, xPlane.CenterOfMass); Plane3 yPlane = new Plane3(Vector3.UnitY, Vector3.Up); Assert.AreEqual(Vector3.Up, yPlane.CenterOfMass); Plane3 zPlane = new Plane3(Vector3.UnitZ, Vector3.Backward); Assert.AreEqual(Vector3.Backward, zPlane.CenterOfMass); }
/// <summary>Determines where the range clips a plane</summary> /// <param name="plane">Plane that will be checked for intersection</param> /// <returns>The times at which the range touches the plane, if at all</returns> public LineContacts FindContacts(Plane3 plane) { return(Collisions.Line3Plane3Collider.FindContacts( Offset, Direction, plane.Offset, plane.Normal )); }
public static int BoxOnPlaneSide(float[] emins, float[] emaxs, Plane3 p) { #if !CODE_ANALYSIS && CLR4 Contract.Assert(emins.Length == 3 && emaxs.Length == 3, "vec3_t bug"); #endif float dist1, dist2; int sides; // fast axial cases if (p.type < 3) { if (p.dist <= emins[p.type]) { return(1); } if (p.dist >= emaxs[p.type]) { return(2); } return(3); } // general case switch (p.signbits) { case 0: dist1 = p.normal[0] * emaxs[0] + p.normal[1] * emaxs[1] + p.normal[2] * emaxs[2]; dist2 = p.normal[0] * emins[0] + p.normal[1] * emins[1] + p.normal[2] * emins[2]; break; case 1: dist1 = p.normal[0] * emins[0] + p.normal[1] * emaxs[1] + p.normal[2] * emaxs[2]; dist2 = p.normal[0] * emaxs[0] + p.normal[1] * emins[1] + p.normal[2] * emins[2]; break; case 2: dist1 = p.normal[0] * emaxs[0] + p.normal[1] * emins[1] + p.normal[2] * emaxs[2]; dist2 = p.normal[0] * emins[0] + p.normal[1] * emaxs[1] + p.normal[2] * emins[2]; break; case 3: dist1 = p.normal[0] * emins[0] + p.normal[1] * emins[1] + p.normal[2] * emaxs[2]; dist2 = p.normal[0] * emaxs[0] + p.normal[1] * emaxs[1] + p.normal[2] * emins[2]; break; case 4: dist1 = p.normal[0] * emaxs[0] + p.normal[1] * emaxs[1] + p.normal[2] * emins[2]; dist2 = p.normal[0] * emins[0] + p.normal[1] * emins[1] + p.normal[2] * emaxs[2]; break; case 5: dist1 = p.normal[0] * emins[0] + p.normal[1] * emaxs[1] + p.normal[2] * emins[2]; dist2 = p.normal[0] * emaxs[0] + p.normal[1] * emins[1] + p.normal[2] * emaxs[2]; break; case 6: dist1 = p.normal[0] * emaxs[0] + p.normal[1] * emins[1] + p.normal[2] * emins[2]; dist2 = p.normal[0] * emins[0] + p.normal[1] * emaxs[1] + p.normal[2] * emaxs[2]; break; case 7: dist1 = p.normal[0] * emins[0] + p.normal[1] * emins[1] + p.normal[2] * emins[2]; dist2 = p.normal[0] * emaxs[0] + p.normal[1] * emaxs[1] + p.normal[2] * emaxs[2]; break; default: dist1 = dist2 = 0; #if !CODE_ANALYSIS && CLR4 Contract.Assert(false, "BoxOnPlaneSide bug"); #endif break; } sides = 0; if (dist1 >= p.dist) { sides = 1; } if (dist2 < p.dist) { sides |= 2; } #if !CODE_ANALYSIS && CLR4 Contract.Assert(sides != 0, "BoxOnPlaneSide(): sides == 0 bug"); #endif return(sides); }
/// <summary> /// Least Squares Fit of 3D points to a plane, according to http://www.geometrictools.com/Documentation/LeastSquaresFitting.pdf /// </summary> /// <param name="points">The 3d points to fit</param> /// <param name="error">the residual error</param> /// <returns>The best-fit plane</returns> public static Plane3 FitPlane(IEnumerable <Vector3> points, out double error) { Matrix m = new Matrix(new int[] { 3, 3 }); double[] b = new double[3]; double m00 = 0; double m01 = 0; double m02 = 0; double m10 = 0; double m11 = 0; double m12 = 0; double m20 = 0; double m21 = 0; double m22 = 0; foreach (var p in points) { m00 += p.X * p.X; m01 += p.X * p.Y; m02 += p.X; m11 += p.Y * p.Y; m12 += p.Y; m22++; b[0] += p.X * p.Z; b[1] += p.Y * p.Z; b[2] += p.Z; } m10 = m01; m20 = m02; m21 = m12; m.M[0][0] = m00; m.M[0][1] = m01; m.M[0][2] = m02; m.M[1][0] = m10; m.M[1][1] = m11; m.M[1][2] = m12; m.M[1][0] = m20; m.M[1][1] = m21; m.M[1][2] = m22; double[] x; m.Gauss(b, true, out x); var r = new Plane3(x[0], x[1], x[2]); double e = 0; foreach (var p in points) { e += (r.A * p.X + r.B * p.Y + r.C - p.Z) * (r.A * p.X + r.B * p.Y + r.C - p.Z); } error = e; return(r); }
public void TestBoundingBoxCalculation() { Vector3 diagonal = Vector3.Normalize(Vector3.One); Plane3 plane = new Plane3(Vector3.Zero, diagonal); Assert.AreEqual( new Volumes.AxisAlignedBox3( new Vector3(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity), new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity) ), plane.BoundingBox ); }
public void TestClosestPointToPlane() { Plane3 xPlane = new Plane3(Vector3.UnitX * 2.0f, Vector3.Right); Assert.AreEqual( new Vector3(2.0f, 20.0f, 30.0f), xPlane.ClosestPointTo(new Vector3(10.0f, 20.0f, 30.0f)) ); Plane3 yPlane = new Plane3(Vector3.UnitY * 2.0f, Vector3.Up); Assert.AreEqual( new Vector3(10.0f, 2.0f, 30.0f), yPlane.ClosestPointTo(new Vector3(10.0f, 20.0f, 30.0f)) ); Plane3 zPlane = new Plane3(Vector3.UnitZ * 2.0f, Vector3.Backward); Assert.AreEqual( new Vector3(10.0f, 20.0f, 2.0f), zPlane.ClosestPointTo(new Vector3(10.0f, 20.0f, 30.0f)) ); }
public void TestBoundingBoxCalculationForXPlane() { Plane3 xPlane = new Plane3(Vector3.UnitX * 2.0f, Vector3.Right); Assert.AreEqual( new Volumes.AxisAlignedBox3( new Vector3(2.0f, float.NegativeInfinity, float.NegativeInfinity), new Vector3(2.0f, float.PositiveInfinity, float.PositiveInfinity) ), xPlane.BoundingBox ); }
/// <summary> /// Tests for an intersection between a ray and a plane /// </summary> public static bool TestRayIntersection( Ray3 ray, Plane3 plane ) { float startDot = plane.Normal.Dot( ray.Origin ); float diffDot = plane.Normal.Dot( ray.Direction ); if ( !Utils.CloseToZero( diffDot ) ) { float t = ( startDot + plane.Distance ) / -diffDot; return ( t >= 0 ); } return false; }
public void TestOffsetConstructor() { Vector3 offset = new Vector3(1.0f, 2.0f, 3.0f); Plane3 plane = new Plane3(offset, Vector3.Up); Assert.AreEqual(offset, plane.Offset); }
public void TestAreaIsInfinite() { Plane3 plane = new Plane3(Vector3.Zero, Vector3.Up); Assert.AreEqual(float.PositiveInfinity, plane.Area); }
public override void Read(AssetStream stream) { base.Read(stream); Type = stream.ReadInt32(); if (IsReadCollisionMode(stream.Version)) { CollisionMode = stream.ReadInt32(); } if (IsReadColliderForce(stream.Version)) { ColliderForce = stream.ReadSingle(); MultiplyColliderForceByParticleSize = stream.ReadBoolean(); MultiplyColliderForceByParticleSpeed = stream.ReadBoolean(); MultiplyColliderForceByCollisionAngle = stream.ReadBoolean(); stream.AlignStream(AlignType.Align4); } Plane0.Read(stream); Plane1.Read(stream); Plane2.Read(stream); Plane3.Read(stream); Plane4.Read(stream); Plane5.Read(stream); if (IsReadDampenSingle(stream.Version)) { DampenSingle = stream.ReadSingle(); BounceSingle = stream.ReadSingle(); EnergyLossOnCollisionSingle = stream.ReadSingle(); } else { Dampen.Read(stream); Bounce.Read(stream); EnergyLossOnCollision.Read(stream); } MinKillSpeed = stream.ReadSingle(); if (IsReadMaxKillSpeed(stream.Version)) { MaxKillSpeed = stream.ReadSingle(); } if (IsReadRadiusScale(stream.Version)) { RadiusScale = stream.ReadSingle(); CollidesWith.Read(stream); } if (IsReadMaxCollisionShapes(stream.Version)) { MaxCollisionShapes = stream.ReadInt32(); } if (IsReadQuality(stream.Version)) { Quality = stream.ReadInt32(); VoxelSize = stream.ReadSingle(); } if (IsReadCollisionMessages(stream.Version)) { CollisionMessages = stream.ReadBoolean(); } if (IsReadCollidesWithDynamic(stream.Version)) { CollidesWithDynamic = stream.ReadBoolean(); InteriorCollisions = stream.ReadBoolean(); stream.AlignStream(AlignType.Align4); } }
public void TestDistanceConstructor() { Plane3 plane = new Plane3(123.0f, Vector3.Up); Assert.AreEqual(123.0f, plane.Offset.Length()); }
public TrPlane(Point3 pos, Vector3 normal, Material mat) : base(Transform3.Identity, mat) { plane = new Plane3(pos, normal); }
public void TestRandomPointWithin() { IRandom randomNumberGenerator = new DefaultRandom(); // A random point has to involve infinity (since the chance that of hitting the // meager numeric range of a float, or any other finite number system, is about // zero for a infinitely large plane). But given the orientation of the plane, // only these combinations of positive and negative infinity can be possible. Vector3[] possiblePoints = new Vector3[] { new Vector3(float.NegativeInfinity, float.PositiveInfinity, float.PositiveInfinity), new Vector3(float.NegativeInfinity, float.NegativeInfinity, float.PositiveInfinity), new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.NegativeInfinity), new Vector3(float.PositiveInfinity, float.NegativeInfinity, float.NegativeInfinity), }; Plane3 plane = new Plane3(Vector3.Zero, Vector3.Normalize(Vector3.One)); for(int index = 0; index < Specifications.ProbabilisticFunctionSamples; ++index) { Vector3 randomPoint = plane.RandomPointWithin(randomNumberGenerator); //Assert.That(randomPoint, Is.OneOf(possiblePoints)); CollectionAssert.Contains(possiblePoints, randomPoint); } }
public override void Read(AssetReader reader) { base.Read(reader); Type = (ParticleSystemCollisionType)reader.ReadInt32(); if (IsReadCollisionMode(reader.Version)) { CollisionMode = (ParticleSystemCollisionMode)reader.ReadInt32(); } if (IsReadColliderForce(reader.Version)) { ColliderForce = reader.ReadSingle(); MultiplyColliderForceByParticleSize = reader.ReadBoolean(); MultiplyColliderForceByParticleSpeed = reader.ReadBoolean(); MultiplyColliderForceByCollisionAngle = reader.ReadBoolean(); reader.AlignStream(AlignType.Align4); } Plane0.Read(reader); Plane1.Read(reader); Plane2.Read(reader); Plane3.Read(reader); Plane4.Read(reader); Plane5.Read(reader); if (IsReadDampenSingle(reader.Version)) { float dampenSingle = reader.ReadSingle(); float bounceSingle = reader.ReadSingle(); float energyLossOnCollisionSingle = reader.ReadSingle(); Dampen = new MinMaxCurve(dampenSingle); Bounce = new MinMaxCurve(bounceSingle); EnergyLossOnCollision = new MinMaxCurve(energyLossOnCollisionSingle); } else { Dampen.Read(reader); Bounce.Read(reader); EnergyLossOnCollision.Read(reader); } MinKillSpeed = reader.ReadSingle(); if (IsReadMaxKillSpeed(reader.Version)) { MaxKillSpeed = reader.ReadSingle(); } if (IsReadRadiusScale(reader.Version)) { RadiusScale = reader.ReadSingle(); CollidesWith.Read(reader); } if (IsReadMaxCollisionShapes(reader.Version)) { MaxCollisionShapes = reader.ReadInt32(); } if (IsReadQuality(reader.Version)) { Quality = (ParticleSystemCollisionQuality)reader.ReadInt32(); VoxelSize = reader.ReadSingle(); } if (IsReadCollisionMessages(reader.Version)) { CollisionMessages = reader.ReadBoolean(); } if (IsReadCollidesWithDynamic(reader.Version)) { CollidesWithDynamic = reader.ReadBoolean(); InteriorCollisions = reader.ReadBoolean(); reader.AlignStream(AlignType.Align4); } }
public void TestBoundingBoxCalculationForZPlane() { Plane3 zPlane = new Plane3(Vector3.UnitZ * 2.0f, Vector3.Backward); Assert.AreEqual( new Volumes.AxisAlignedBox3( new Vector3(float.NegativeInfinity, float.NegativeInfinity, 2.0f), new Vector3(float.PositiveInfinity, float.PositiveInfinity, 2.0f) ), zPlane.BoundingBox ); }
/// <summary>Determines where the range clips a plane</summary> /// <param name="plane">Plane that will be checked for intersection</param> /// <returns>The times at which the range touches the plane, if at all</returns> public LineContacts FindContacts(Plane3 plane) { return Collisions.Line3Plane3Collider.FindContacts( Offset, Direction, plane.Offset, plane.Normal ); }
public void TestCircumferenceIsInfinite() { Plane3 plane = new Plane3(Vector3.Zero, Vector3.Up); Assert.AreEqual(float.PositiveInfinity, plane.CircumferenceLength); }
public void UpdatePlane(Plane3 update) { UpdateTransformPlane(transform, update); plane = update; planeText.text = PlaneEquation(); }
/// <summary>Get the intersection point between the three planes.</summary> public void Intersect( ref Plane3 b, ref Plane3 c , out Vector3 result) { Vector3d v1, v2, v3; Vector3d cross; b.Normal.Cross(ref c.Normal, out cross); var f = -Normal.Dot(ref cross); v1 = cross * ( Distance ).InUniversal; c.Normal.Cross(ref Normal, out cross); v2 = cross * ( b.Distance ).InUniversal; Normal.Cross(ref b.Normal, out cross); v3 = cross * ( c.Distance ).InUniversal; result.X = Length.Universal( (v1.X + v2.X + v3.X) / f ); result.Y = Length.Universal( (v1.Y + v2.Y + v3.Y) / f ); result.Z = Length.Universal( (v1.Z + v2.Z + v3.Z) / f ); return; }
// Token: 0x06000016 RID: 22 RVA: 0x00002E10 File Offset: 0x00001010 private static void ProjectToPlane(List <Vector3> vertices, int sweepCount, UnitVector3 direction, Plane3 plane) { int num = vertices.Count - sweepCount; for (int i = 0; i < sweepCount; i++) { Ray3 ray = new Ray3(vertices[num + i], direction); Vector3?vector = plane.IntersectionWith(ray); vertices.Add((vector != null) ? vector.Value : vertices[num + i]); } }
public void TestRandomPointWithinForZPlane() { IRandom randomNumberGenerator = new DefaultRandom(); Plane3 zPlane = new Plane3(Vector3.UnitZ * 2.0f, Vector3.Backward); for(int index = 0; index < Specifications.ProbabilisticFunctionSamples; ++index) { Vector3 randomPoint = zPlane.RandomPointWithin(randomNumberGenerator); Assert.IsTrue(float.IsInfinity(randomPoint.X)); Assert.IsTrue(float.IsInfinity(randomPoint.Y)); Assert.AreEqual(2.0f, randomPoint.Z); } }
/// <summary>Determines where the range clips a plane</summary> /// <param name="plane">Plane that will be checked for intersection</param> /// <returns>The times at which the range touches the plane, if at all</returns> public LineContacts FindContacts(Plane3 plane) { LineContacts contacts = Collisions.Line3Plane3Collider.FindContacts( Start, End - Start, plane.Offset, plane.Normal ); limitContactToLineSegment(ref contacts); return contacts; }
/// <summary> /// Create rhino plane from karamba plane. /// </summary> /// /// <param name="p"></param> /// <returns></returns> public static Plane Convert(this Plane3 p) { return(new Plane(p.Origin.Convert(), p.XAxis.Convert(), p.YAxis.Convert())); }