/// <summary> /// Initializes a new RCNumRectangle with the specified location and size. /// </summary> /// <param name="loc">The location of the top-left corner of the RCNumRectangle.</param> /// <param name="size">The size of the RCNumRectangle.</param> public RCNumRectangle(RCNumVector loc, RCNumVector size) { if (loc == RCNumVector.Undefined) { throw new ArgumentNullException("loc"); } if (size == RCNumVector.Undefined) { throw new ArgumentNullException("size"); } if (size.X <= 0) { throw new ArgumentOutOfRangeException("Width has to be greater than 0!", "width"); } if (size.Y <= 0) { throw new ArgumentOutOfRangeException("Height has to be greater than 0!", "height"); } this.isDefined = true; this.x = loc.X; this.y = loc.Y; this.width = size.X; this.height = size.Y; }
/// <summary> /// Collects every content attached to this BspSearchTreeNode at the given position. /// </summary> /// <param name="position">The position to check.</param> /// <param name="outputList"> /// A list the contains every content attached to this BspSearchTreeNode at the given position. /// </param> public void CollectContents(RCNumVector position, ref RCSet <T> outputList) { if (this.isLeaf) { /// Leaf node -> collect the contents at the given position foreach (T content in this.contents) { if (content.BoundingBox.Contains(position)) { outputList.Add(content); } } } else { /// Not a leaf node -> propagate the call to the appropriate child. if (this.firstChild.area.Contains(position)) { this.firstChild.CollectContents(position, ref outputList); } else if (this.secondChild.area.Contains(position)) { this.secondChild.CollectContents(position, ref outputList); } } }
/// <summary> /// Transforms the coordinates of the given vector from coordinate-system B to A. /// </summary> /// <param name="vect">The vector to be transformed.</param> /// <returns>The transformed vector.</returns> public RCNumVector TransformBA(RCNumVector vect) { if (vect == RCNumVector.Undefined) { throw new ArgumentNullException("vect"); } return(this.transformBA * vect + this.nullVectorOfB); }
/// <summary> /// Determines if the specified point is contained within this RCNumRectangle. /// </summary> /// <param name="point">The point to test.</param> /// <returns>Returns true if the point is contained within this RCNumRectangle, false otherwise.</returns> public bool Contains(RCNumVector point) { if (!this.isDefined) { throw new InvalidOperationException("Illegal use of undefined RCNumRectangle!"); } if (point == RCNumVector.Undefined) { throw new ArgumentNullException("point"); } return(this.Contains(point.X, point.Y)); }
/// <summary> /// Initializes a new RCNumVector with the specified RCNumVector. /// </summary> /// <param name="other">The RCNumVector to initialize with.</param> public RCNumVector(RCNumVector other) { if (!other.isDefined) { throw new ArgumentNullException("other"); } this.isDefined = true; this.x = other.x; this.y = other.y; this.lengthCache = default(CachedValue <RCNumber>); this.lengthCacheCreated = false; }
/// <see cref="ISearchTree<T>.GetContents"/> public RCSet <T> GetContents(RCNumVector position) { if (position == RCNumVector.Undefined) { throw new ArgumentNullException("position"); } RCSet <T> retList = new RCSet <T>(); this.rootNode.CollectContents(position, ref retList); return(retList); }
/// <summary> /// Constructs an RCCoordTransformation instance. /// </summary> /// <param name="nullVectorOfB">The null vector of coordinate-system B in coordinate-system A.</param> /// <param name="firstBaseVectorOfB">The first base vector of coordinate-system B in coordinate-system A.</param> /// <param name="secondBaseVectorOfB">The second base vector of coordinate-system B in coordinate-system A.</param> public RCCoordTransformation(RCNumVector nullVectorOfB, RCNumVector firstBaseVectorOfB, RCNumVector secondBaseVectorOfB) { if (nullVectorOfB == RCNumVector.Undefined) { throw new ArgumentNullException("nullVectorOfB"); } if (firstBaseVectorOfB == RCNumVector.Undefined) { throw new ArgumentNullException("firstBaseVectorOfB"); } if (secondBaseVectorOfB == RCNumVector.Undefined) { throw new ArgumentNullException("secondBaseVectorOfB"); } this.nullVectorOfB = nullVectorOfB; this.transformBA = new RCMatrix(firstBaseVectorOfB, secondBaseVectorOfB); this.transformAB = this.transformBA.Inverse; }
/// <summary> /// Creates an RCMatrix with the given columns. /// </summary> /// <param name="col0">The first column of the matrix.</param> /// <param name="col0">The second column of the matrix.</param> public RCMatrix(RCNumVector col0, RCNumVector col1) { if (col0 == RCNumVector.Undefined) { throw new ArgumentNullException("col0"); } if (col1 == RCNumVector.Undefined) { throw new ArgumentNullException("col1"); } this.item00 = col0.X; this.item01 = col1.X; this.item10 = col0.Y; this.item11 = col1.Y; this.determinantCache = default(CachedValue <RCNumber>); this.determinantCacheCreated = false; this.inverseCache = default(CachedValue <RCMatrixInternal>); this.inverseCacheCreated = false; }
/// <summary> /// Checks whether this RCNumVector contains the same coordinates as the specified RCNumVector. /// </summary> /// <param name="other">The RCNumVector to test.</param> /// <returns>True if other RCNumVector has the same coordinates as this RCNumVector.</returns> public bool Equals(RCNumVector other) { return((!this.isDefined && !other.isDefined) || (this.isDefined && other.isDefined && this.x == other.x && this.y == other.y)); }