Esempio n. 1
0
        internal static float ConvertSweepAngle(float sweepAngle, float startAngle, SpatialTransform transform, CoordinateSystem targetSystem)
        {
            PointF x = new PointF(100, 0);

            PointF[] startVector = new PointF[] { x };
            Matrix   rotation    = new Matrix();

            rotation.Rotate(startAngle);
            rotation.TransformVectors(startVector);

            PointF[] sweepVector = (PointF[])startVector.Clone();
            rotation.Reset();
            rotation.Rotate(sweepAngle);
            rotation.TransformVectors(sweepVector);
            rotation.Dispose();

            SizeF startVectorTransformed, sweepVectorTransformed;

            if (targetSystem == Graphics.CoordinateSystem.Destination)
            {
                startVectorTransformed = transform.ConvertToDestination(new SizeF(startVector[0]));
                sweepVectorTransformed = transform.ConvertToDestination(new SizeF(sweepVector[0]));
            }
            else
            {
                startVectorTransformed = transform.ConvertToSource(new SizeF(startVector[0]));
                sweepVectorTransformed = transform.ConvertToSource(new SizeF(sweepVector[0]));
            }

            // simply return the angle between the start and sweep angle, in the target system.
            return((int)Math.Round(Vector.SubtendedAngle(sweepVectorTransformed.ToPointF(), PointF.Empty, startVectorTransformed.ToPointF())));
        }
Esempio n. 2
0
        internal static float ConvertStartAngle(float angle, SpatialTransform transform, CoordinateSystem targetSystem)
        {
            PointF xVector = new PointF(100, 0);

            Matrix rotation = new Matrix();

            PointF[] angleVector = new PointF[] { xVector };
            rotation.Rotate(angle);
            rotation.TransformVectors(angleVector);
            rotation.Dispose();

            SizeF xVectorTransformed, angleVectorTransformed;

            if (targetSystem == Graphics.CoordinateSystem.Destination)
            {
                xVectorTransformed     = transform.ConvertToDestination(new SizeF(xVector));
                angleVectorTransformed = transform.ConvertToDestination(new SizeF(angleVector[0]));
            }
            else
            {
                xVectorTransformed     = transform.ConvertToSource(new SizeF(xVector));
                angleVectorTransformed = transform.ConvertToSource(new SizeF(angleVector[0]));
            }

            float xRotationOffset =
                (int)Math.Round(Vector.SubtendedAngle(xVectorTransformed.ToPointF(), PointF.Empty, xVector));

            float angleTransformed =
                (int)Math.Round(Vector.SubtendedAngle(angleVectorTransformed.ToPointF(), PointF.Empty, xVectorTransformed.ToPointF()));

            // have to figure out where x-axis moved to and then return the difference between the angle
            // and the x-axis, where both are in 'target' coordinates.
            float returnAngle = angleTransformed + xRotationOffset;

            if (returnAngle < 0)
            {
                returnAngle += 360;
            }

            return(returnAngle);
        }
Esempio n. 3
0
		internal static float ConvertSweepAngle(float sweepAngle, float startAngle, SpatialTransform transform, CoordinateSystem targetSystem)
		{
			PointF x = new PointF(100, 0);

			PointF[] startVector = new PointF[] { x };
			Matrix rotation = new Matrix();
			rotation.Rotate(startAngle);
			rotation.TransformVectors(startVector);

			PointF[] sweepVector = (PointF[])startVector.Clone();
			rotation.Reset();
			rotation.Rotate(sweepAngle);
			rotation.TransformVectors(sweepVector);
			rotation.Dispose();

			SizeF startVectorTransformed, sweepVectorTransformed;
			if (targetSystem == Graphics.CoordinateSystem.Destination)
			{
				startVectorTransformed = transform.ConvertToDestination(new SizeF(startVector[0]));
				sweepVectorTransformed = transform.ConvertToDestination(new SizeF(sweepVector[0]));
			}
			else
			{
				startVectorTransformed = transform.ConvertToSource(new SizeF(startVector[0]));
				sweepVectorTransformed = transform.ConvertToSource(new SizeF(sweepVector[0]));
			}

			// simply return the angle between the start and sweep angle, in the target system.
			return (int)Math.Round(Vector.SubtendedAngle(sweepVectorTransformed.ToPointF(), PointF.Empty, startVectorTransformed.ToPointF()));
		}
Esempio n. 4
0
		internal static float ConvertStartAngle(float angle, SpatialTransform transform, CoordinateSystem targetSystem)
		{
			PointF xVector = new PointF(100, 0);

			Matrix rotation = new Matrix();
			PointF[] angleVector = new PointF[] { xVector };
			rotation.Rotate(angle);
			rotation.TransformVectors(angleVector);
			rotation.Dispose();

			SizeF xVectorTransformed, angleVectorTransformed;
			if (targetSystem == Graphics.CoordinateSystem.Destination)
			{
				xVectorTransformed = transform.ConvertToDestination(new SizeF(xVector));
				angleVectorTransformed = transform.ConvertToDestination(new SizeF(angleVector[0]));
			}
			else
			{
				xVectorTransformed = transform.ConvertToSource(new SizeF(xVector));
				angleVectorTransformed = transform.ConvertToSource(new SizeF(angleVector[0]));
			}

			float xRotationOffset =
				(int)Math.Round(Vector.SubtendedAngle(xVectorTransformed.ToPointF(), PointF.Empty, xVector));

			float angleTransformed =
				(int)Math.Round(Vector.SubtendedAngle(angleVectorTransformed.ToPointF(), PointF.Empty, xVectorTransformed.ToPointF()));

			// have to figure out where x-axis moved to and then return the difference between the angle
			// and the x-axis, where both are in 'target' coordinates.
			float returnAngle = angleTransformed + xRotationOffset;
			if (returnAngle < 0)
				returnAngle += 360;

			return returnAngle;
		}
		/// <summary>
		/// Called by GetAnnotationText (and also by Unit Test code).  Making this function internal simply makes it easier
		/// to write unit tests for this class (don't have to implement a fake PresentationImage).
		/// </summary>
		/// <param name="imageTransform">the image transform</param>
		/// <param name="imageOrientationPatient">the image orientation patient (direction cosines)</param>
		/// <returns></returns>
		internal string GetAnnotationTextInternal(SpatialTransform imageTransform, ImageOrientationPatient imageOrientationPatient)
		{
			SizeF[] imageEdgeVectors = new SizeF[4];
			for (int i = 0; i < 4; ++i)
				imageEdgeVectors[i] = imageTransform.ConvertToDestination(_edgeVectors[i]);

			//find out which source image edge got transformed to coincide with this viewport edge.
			ImageEdge transformedEdge = GetTransformedEdge(imageEdgeVectors);

			//get the marker for the appropriate (source) image edge.
			return GetMarker(transformedEdge, imageOrientationPatient);
		}