/// <summary> /// Gets two points defining the axis of the object. /// </summary> /// public LineSegment GetAxis(AxisOrientation axis) { double x1, y1; double x2, y2; if (axis == AxisOrientation.Horizontal) { y1 = Math.Cos(-Angle - Math.PI) * Rectangle.Height / 2.0; x1 = Math.Sin(-Angle - Math.PI) * Rectangle.Width / 2.0; y2 = Math.Cos(-Angle) * Rectangle.Height / 2.0; x2 = Math.Sin(-Angle) * Rectangle.Width / 2.0; } else { y1 = Math.Cos(-(Angle + Math.PI / 2) - Math.PI) * Rectangle.Height / 2.0; x1 = Math.Sin(-(Angle + Math.PI / 2) - Math.PI) * Rectangle.Width / 2.0; y2 = Math.Cos(-(Angle + Math.PI / 2)) * Rectangle.Height / 2.0; x2 = Math.Sin(-(Angle + Math.PI / 2)) * Rectangle.Width / 2.0; } Point start = new Point((float)(Center.X + x1), (float)(Center.Y + y1)); Point end = new Point((float)(Center.X + x2), (float)(Center.Y + y2)); if (start.DistanceTo(end) == 0) { return(null); } return(new LineSegment(start, end)); }
/// <summary> /// Initializes a new instance of the <see cref="Blob"/> class. /// </summary> /// /// <param name="source">Source blob to copy.</param> /// /// <remarks><para>This copy constructor leaves <see cref="Image"/> property not initialized. The blob's /// image may be extracted later using <see cref="BlobCounterBase.ExtractBlobsImage( Bitmap, Blob, bool )"/> /// or <see cref="BlobCounterBase.ExtractBlobsImage( UnmanagedImage, Blob, bool )"/> method.</para></remarks> /// public Blob(Blob source) { // copy everything except image id = source.id; rect = source.rect; cog = source.cog; area = source.area; fullness = source.fullness; colorMean = source.colorMean; colorStdDev = source.colorStdDev; }
/// <summary> /// Initializes a new instance of the <see cref="Blob"/> class. /// </summary> /// /// <param name="source">Source blob to copy.</param> /// /// <remarks><para>This copy constructor leaves <see cref="Image"/> property not initialized. The blob's /// image may be extracted later using <see cref="BlobCounterBase.ExtractBlobsImage( Bitmap, Blob, bool )"/> /// or <see cref="BlobCounterBase.ExtractBlobsImage( UnmanagedImage, Blob, bool )"/> method.</para></remarks> /// public Blob( Blob source ) { // copy everything except image id = source.id; rect = source.rect; cog = source.cog; area = source.area; fullness = source.fullness; colorMean = source.colorMean; colorStdDev = source.colorStdDev; }