/// <summary> /// Gets the <see cref="PointF"/> with central offset of a <see cref="nestPoint"/>, identified by <c>nestID</c>. /// </summary> /// <value> /// The <see cref="PointF"/>, describing X,Y offset from central point of the <see cref="circularDisplacer"/> instance and <see cref="nestPoint"/> identified by <c>nestID</c>. /// </value> /// <param name="nestID">The nest identifier (from 0 to nest count-1). If negative value, it is interpreted as selecting the nest from end of the list, not from the begining.</param> /// <returns>Point with X and Y axis central point offset.</returns> /// <exception cref="ArgumentOutOfRangeException">nestID - There are no nestpoints defined in this instance! Seems you are using wrong constructor/instancing approach.</exception> public PointF this[Int32 nestID] { get { if (!points.Any()) { throw new ArgumentOutOfRangeException(nameof(nestID), "There are no nestpoints defined in this instance! Seems you are using wrong constructor/instancing approach."); } if (nestID < 0) { nestID = nestID % points.Count; nestID = points.Count + nestID; } if (nestID >= points.Count) { throw new ArgumentOutOfRangeException(nameof(nestID), "There are [" + points.Count + "] in the turret, can't select specified [" + nestID + "]. The max. is [" + (points.Count - 1) + "] no nestpoints defined in this instance! Seems you are using wrong constructor/instancing approach."); } nestPoint np = points[nestID]; Double d = np.angularPosition.Degrees; var _x = Math.Cos(d) * np.distanceFromCenter; var _y = Math.Sin(d) * np.distanceFromCenter; PointF output = new PointF((float)_x, (float)_y); return(output); } }
/// <summary> /// Creates instance with <c>nestCount</c> of <see cref="nestPoint"/>s, placed in full circle, having even angular distances. The first <see cref="nestPoint"/> has <see cref="nestPoint.angularPosition"/> of the <c>zeroOffset</c>. The <see cref="nestPoint"/>s are placed at <c>distance</c> from central point of the wheel /// </summary> /// <param name="nestCount">Number of <see cref="nestPoint"/>s to create</param> /// <param name="zeroOffset">Angular starting point for the first nest point</param> /// <param name="distance">Distance from central point - to be set for all <see cref="nestPoint"/>s.</param> public circularDisplacer(Int32 nestCount = 6, Double zeroOffset = 30, Double distance = 35.5) { Double step = 360 / nestCount; for (int i = 0; i < nestCount; i++) { Double a = (step * i) + zeroOffset; var n = new nestPoint(a, distance); points.Add(n); } }