/// <summary> /// Construct a new nearest neighbour iterator. /// </summary> /// <param name="pRoot">The root of the tree to begin searching from.</param> /// <param name="tSearchPoint">The point in n-dimensional space to search.</param> /// <param name="kDistance">The distance function used to evaluate the points.</param> /// <param name="iMaxPoints">The max number of points which can be returned by this iterator. Capped to max in tree.</param> /// <param name="fThreshold">Threshold to apply to the search space. Negative numbers indicate that no threshold is applied.</param> public NearestNeighbour(KDNode pRoot, Vector3d tSearchPoint, DistanceFunctions kDistance, int iMaxPoints, double fThreshold) { // Store the search point. this.tSearchPoint = new Vector3d(tSearchPoint); // Store the point count, distance function and tree root. this.iPointsRemaining = Math.Min(iMaxPoints, pRoot.Size); this.fThreshold = fThreshold; this.kDistanceFunction = kDistance; this.pRoot = pRoot; this.iMaxPointsReturned = iMaxPoints; _CurrentDistance = -1; // Create an interval heap for the points we check. this.pEvaluated = new IntervalHeap(); // Create a min heap for the things we need to check. this.pPending = new MinHeap(); this.pPending.Insert(0, pRoot); }
/// <summary> /// Get the nearest neighbours to a point in the kd tree using a user defined distance function. /// </summary> /// <param name="tSearchPoint">The point of interest.</param> /// <param name="iMaxReturned">The maximum number of points which can be returned by the iterator.</param> /// <param name="kDistanceFunction">The distance function to use.</param> /// <param name="fDistance">A threshold distance to apply. Optional. Negative values mean that it is not applied.</param> /// <returns>A new nearest neighbour iterator with the given parameters.</returns> public NearestNeighbour NearestNeighbors(Vector3d tSearchPoint, DistanceFunctions kDistanceFunction, int iMaxReturned, double fDistance) { return new NearestNeighbour(this, tSearchPoint, kDistanceFunction, iMaxReturned, fDistance); }
/// <summary> /// Explicit Constructor /// </summary> /// <param name="sPositionOnPlane">A 3D Position on the Plane Magnet's Plane</param> /// <param name="sNormal">The Normal direction of the Plane (i.e. the up direction away from the plane)</param> /// <param name="eMode">The Mode that the Magnet should be in</param> /// <param name="eDistanceFunction">The Function to use to determine how much a Particle should be affected by /// the Magnet based on how far away from the Magnet it is</param> /// <param name="fMinDistance">The Min Distance that the Magnet should be able to affect Particles at. If the /// Particle is closer to the Magnet than this distance, the Magnet will not affect the Particle.</param> /// <param name="fMaxDistance">The Max Distance that the Magnet should be able to affect Particles at. If the /// Particle is further away from the Magnet tan this distance, the Manget will not affect the Particle.</param> /// <param name="fMaxForce">The Max Force that the Magnet is able to exert on a Particle</param> /// <param name="iType">The Type of Magnet this is. This may be used in conjunction with the "Other" Magnet /// Mode to distinguish which type of custom user effect the Magnet should have on the Particles.</param> public MagnetPlane(Vector3 sPositionOnPlane, Vector3 sNormal, MagnetModes eMode, DistanceFunctions eDistanceFunction, float fMinDistance, float fMaxDistance, float fMaxForce, int iType) : base(eMode, eDistanceFunction, fMinDistance, fMaxDistance, fMaxForce, iType) { meMagnetType = MagnetTypes.PlaneMagnet; PositionOnPlane = sPositionOnPlane; Normal = sNormal; }
/// <summary> /// Explicit Constructor /// </summary> /// <param name="sEndPoint1Position">The 3D position of the first End Point of the Line Segment Magnet</param> /// <param name="sEndPoint2Position">The 3D position of the second End Point of the Line Segment Magnet</param> /// <param name="eMode">The Mode that the Magnet should be in</param> /// <param name="eDistanceFunction">The Function to use to determine how much a Particle should be affected by /// the Magnet based on how far away from the Magnet it is</param> /// <param name="fMinDistance">The Min Distance that the Magnet should be able to affect Particles at. If the /// Particle is closer to the Magnet than this distance, the Magnet will not affect the Particle.</param> /// <param name="fMaxDistance">The Max Distance that the Magnet should be able to affect Particles at. If the /// Particle is further away from the Magnet tan this distance, the Manget will not affect the Particle.</param> /// <param name="fMaxForce">The Max Force that the Magnet is able to exert on a Particle</param> /// <param name="iType">The Type of Magnet this is. This may be used in conjunction with the "Other" Magnet /// Mode to distinguish which type of custom user effect the Magnet should have on the Particles.</param> public MagnetLineSegment(Vector3 sEndPoint1Position, Vector3 sEndPoint2Position, MagnetModes eMode, DistanceFunctions eDistanceFunction, float fMinDistance, float fMaxDistance, float fMaxForce, int iType) : base(eMode, eDistanceFunction, fMinDistance, fMaxDistance, fMaxForce, iType) { meMagnetType = MagnetTypes.LineSegmentMagnet; EndPoint1 = sEndPoint1Position; EndPoint2 = sEndPoint2Position; }
/// <summary> /// Explicit Constructor /// </summary> /// <param name="sPositionOnLine">A 3D Position that the Line Magnet passes through</param> /// <param name="sDirection">The Direction that the Line points in</param> /// <param name="eMode">The Mode that the Magnet should be in</param> /// <param name="eDistanceFunction">The Function to use to determine how much a Particle should be affected by /// the Magnet based on how far away from the Magnet it is</param> /// <param name="fMinDistance">The Min Distance that the Magnet should be able to affect Particles at. If the /// Particle is closer to the Magnet than this distance, the Magnet will not affect the Particle.</param> /// <param name="fMaxDistance">The Max Distance that the Magnet should be able to affect Particles at. If the /// Particle is further away from the Magnet tan this distance, the Manget will not affect the Particle.</param> /// <param name="fMaxForce">The Max Force that the Magnet is able to exert on a Particle</param> /// <param name="iType">The Type of Magnet this is. This may be used in conjunction with the "Other" Magnet /// Mode to distinguish which type of custom user effect the Magnet should have on the Particles.</param> public MagnetLine(Vector3 sPositionOnLine, Vector3 sDirection, MagnetModes eMode, DistanceFunctions eDistanceFunction, float fMinDistance, float fMaxDistance, float fMaxForce, int iType) : base(eMode, eDistanceFunction, fMinDistance, fMaxDistance, fMaxForce, iType) { meMagnetType = MagnetTypes.LineMagnet; PositionOnLine = sPositionOnLine; Direction = sDirection; }
/// <summary> /// Explicit Constructor /// </summary> /// <param name="cPositionData">The 3D Position, Velocity, and Acceleration of the Magnet</param> /// <param name="eMode">The Mode that the Magnet should be in</param> /// <param name="eDistanceFunction">The Function to use to determine how much a Particle should be affected by /// the Magnet based on how far away from the Magnet it is</param> /// <param name="fMinDistance">The Min Distance that the Magnet should be able to affect Particles at. If the /// Particle is closer to the Magnet than this distance, the Magnet will not affect the Particle.</param> /// <param name="fMaxDistance">The Max Distance that the Magnet should be able to affect Particles at. If the /// Particle is further away from the Magnet tan this distance, the Manget will not affect the Particle.</param> /// <param name="fMaxForce">The Max Force that the Magnet is able to exert on a Particle</param> /// <param name="iType">The Type of Magnet this is. This may be used in conjunction with the "Other" Magnet /// Mode to distinguish which type of custom user effect the Magnet should have on the Particles.</param> public MagnetPoint(Position3D cPositionData, MagnetModes eMode, DistanceFunctions eDistanceFunction, float fMinDistance, float fMaxDistance, float fMaxForce, int iType) : base(eMode, eDistanceFunction, fMinDistance, fMaxDistance, fMaxForce, iType) { meMagnetType = MagnetTypes.PointMagnet; PositionData = cPositionData; }
/// <summary> /// Explicit Constructor /// </summary> /// <param name="sPosition">The 3D Position of the Magnet</param> /// <param name="eMode">The Mode that the Magnet should be in</param> /// <param name="eDistanceFunction">The Function to use to determine how much a Particle should be affected by /// the Magnet based on how far away from the Magnet it is</param> /// <param name="fMinDistance">The Min Distance that the Magnet should be able to affect Particles at. If the /// Particle is closer to the Magnet than this distance, the Magnet will not affect the Particle.</param> /// <param name="fMaxDistance">The Max Distance that the Magnet should be able to affect Particles at. If the /// Particle is further away from the Magnet tan this distance, the Manget will not affect the Particle.</param> /// <param name="fMaxForce">The Max Force that the Magnet is able to exert on a Particle</param> /// <param name="iType">The Type of Magnet this is. This may be used in conjunction with the "Other" Magnet /// Mode to distinguish which type of custom user effect the Magnet should have on the Particles.</param> public MagnetPoint(Vector3 sPosition, MagnetModes eMode, DistanceFunctions eDistanceFunction, float fMinDistance, float fMaxDistance, float fMaxForce, int iType) : base(eMode, eDistanceFunction, fMinDistance, fMaxDistance, fMaxForce, iType) { meMagnetType = MagnetTypes.PointMagnet; PositionData.Position = sPosition; }
/// <summary> /// Copies the given Magnet's data into this Magnet's data /// </summary> /// <param name="cMagnetToCopy">The Magnet to copy from</param> public void CopyFrom(DefaultParticleSystemMagnet cMagnetToCopy) { Mode = cMagnetToCopy.Mode; DistanceFunction = cMagnetToCopy.DistanceFunction; meMagnetType = cMagnetToCopy.MagnetType; MinDistance = cMagnetToCopy.MinDistance; MaxDistance = cMagnetToCopy.MaxDistance; MaxForce = cMagnetToCopy.MaxForce; UserDefinedMagnetType = cMagnetToCopy.UserDefinedMagnetType; }
/// <summary> /// Explicit Constructor /// </summary> /// <param name="eMode">The Mode that the Magnet should be in</param> /// <param name="eDistanceFunction">The Function to use to determine how much a Particle should be affected by /// the Magnet based on how far away from the Magnet it is</param> /// <param name="fMinDistance">The Min Distance that the Magnet should be able to affect Particles at. If the /// Particle is closer to the Magnet than this distance, the Magnet will not affect the Particle.</param> /// <param name="fMaxDistance">The Max Distance that the Magnet should be able to affect Particles at. If the /// Particle is further away from the Magnet tan this distance, the Manget will not affect the Particle.</param> /// <param name="fMaxForce">The Max Force that the Magnet is able to exert on a Particle</param> /// <param name="iType">The Type of Magnet this is. This may be used in conjunction with the "Other" Magnet /// Mode to distinguish which type of custom user effect the Magnet should have on the Particles.</param> public DefaultParticleSystemMagnet(MagnetModes eMode, DistanceFunctions eDistanceFunction, float fMinDistance, float fMaxDistance, float fMaxForce, int iType) { Mode = eMode; DistanceFunction = eDistanceFunction; MinDistance = fMinDistance; MaxDistance = fMaxDistance; MaxForce = fMaxForce; UserDefinedMagnetType = iType; }