Esempio n. 1
0
 /// <summary>
 /// Prepends a transformation matrix <paramref name="l"/> to this matrix, and returns a new matrix with the result. The original matrix is unchanged.
 /// </summary>
 /// <param name="l">The matrix to prepend.</param>
 /// <returns>A new matrix based on the existing one, but with matrix <paramref name="l"/> prepended.</returns>
 public Matrix4x3 WithPrependedTransformation(Matrix4x3 l)
 {
     return(new Matrix4x3(
                l.M11 * M11 + l.M12 * M21 + l.M13 * M31,
                l.M11 * M12 + l.M12 * M22 + l.M13 * M32,
                l.M11 * M13 + l.M12 * M23 + l.M13 * M33,
                l.M21 * M11 + l.M22 * M21 + l.M23 * M31,
                l.M21 * M12 + l.M22 * M22 + l.M23 * M32,
                l.M21 * M13 + l.M22 * M23 + l.M23 * M33,
                l.M31 * M11 + l.M32 * M21 + l.M33 * M31,
                l.M31 * M12 + l.M32 * M22 + l.M33 * M32,
                l.M31 * M13 + l.M32 * M23 + l.M33 * M33,
                l.M41 * M11 + l.M42 * M21 + l.M43 * M31 + M41,
                l.M41 * M12 + l.M42 * M22 + l.M43 * M32 + M42,
                l.M41 * M13 + l.M42 * M23 + l.M43 * M33 + M43,
                l.Determinant * Determinant
                ));
 }
Esempio n. 2
0
        /// <summary>
        /// Appends a transformation matrix <paramref name="f"/> to this matrix, and returns a new matrix with the result. The original matrix is unchanged.
        /// </summary>
        /// <param name="f">The matrix to append.</param>
        /// <returns>A new matrix based on the existing one, but with matrix <paramref name="f"/> appended.</returns>
        public Matrix4x3 WithAppendedTransformation(Matrix4x3 f)
        {
            return(new Matrix4x3(
                       M11 * f.M11 + M12 * f.M21 + M13 * f.M31,
                       M11 * f.M12 + M12 * f.M22 + M13 * f.M32,
                       M11 * f.M13 + M12 * f.M23 + M13 * f.M33,

                       M21 * f.M11 + M22 * f.M21 + M23 * f.M31,
                       M21 * f.M12 + M22 * f.M22 + M23 * f.M32,
                       M21 * f.M13 + M22 * f.M23 + M23 * f.M33,

                       M31 * f.M11 + M32 * f.M21 + M33 * f.M31,
                       M31 * f.M12 + M32 * f.M22 + M33 * f.M32,
                       M31 * f.M13 + M32 * f.M23 + M33 * f.M33,

                       M41 * f.M11 + M42 * f.M21 + M43 * f.M31 + f.M41,
                       M41 * f.M12 + M42 * f.M22 + M43 * f.M32 + f.M42,
                       M41 * f.M13 + M42 * f.M23 + M43 * f.M33 + f.M43,

                       Determinant * f.Determinant
                       ));
        }
Esempio n. 3
0
		/// <summary>
		/// Appends a transformation matrix <paramref name="f"/> to this matrix.
		/// </summary>
		/// <param name="f">The matrix to append.</param>
		public void AppendTransform(Matrix4x3 f)
		{
			double h1, h2, h3;

			h1 = M11 * f.M11 + M12 * f.M21 + M13 * f.M31;
			h2 = M11 * f.M12 + M12 * f.M22 + M13 * f.M32;
			h3 = M11 * f.M13 + M12 * f.M23 + M13 * f.M33;
			M11 = h1; M12 = h2; M13 = h3;

			h1 = M21 * f.M11 + M22 * f.M21 + M23 * f.M31;
			h2 = M21 * f.M12 + M22 * f.M22 + M23 * f.M32;
			h3 = M21 * f.M13 + M22 * f.M23 + M23 * f.M33;
			M21 = h1; M22 = h2; M23 = h3;

			h1 = M31 * f.M11 + M32 * f.M21 + M33 * f.M31;
			h2 = M31 * f.M12 + M32 * f.M22 + M33 * f.M32;
			h3 = M31 * f.M13 + M32 * f.M23 + M33 * f.M33;
			M31 = h1; M32 = h2; M33 = h3;

			h1 = M41 * f.M11 + M42 * f.M21 + M43 * f.M31 + f.M41;
			h2 = M41 * f.M12 + M42 * f.M22 + M43 * f.M32 + f.M42;
			h3 = M41 * f.M13 + M42 * f.M23 + M43 * f.M33 + f.M43;
			M41 = h1; M42 = h2; M43 = h3;

			Determinant *= f.Determinant;
		}
Esempio n. 4
0
		/// <summary>
		/// Appends a transformation matrix <paramref name="f"/> to this matrix, and returns a new matrix with the result. The original matrix is unchanged.
		/// </summary>
		/// <param name="f">The matrix to append.</param>
		/// <returns>A new matrix based on the existing one, but with matrix <paramref name="f"/> appended.</returns>
		public Matrix4x3 WithAppendedTransformation(Matrix4x3 f)
		{
			return new Matrix4x3(
			 M11 * f.M11 + M12 * f.M21 + M13 * f.M31,
			 M11 * f.M12 + M12 * f.M22 + M13 * f.M32,
			 M11 * f.M13 + M12 * f.M23 + M13 * f.M33,

			M21 * f.M11 + M22 * f.M21 + M23 * f.M31,
			M21 * f.M12 + M22 * f.M22 + M23 * f.M32,
			M21 * f.M13 + M22 * f.M23 + M23 * f.M33,

			M31 * f.M11 + M32 * f.M21 + M33 * f.M31,
			M31 * f.M12 + M32 * f.M22 + M33 * f.M32,
			M31 * f.M13 + M32 * f.M23 + M33 * f.M33,

			M41 * f.M11 + M42 * f.M21 + M43 * f.M31 + f.M41,
			M41 * f.M12 + M42 * f.M22 + M43 * f.M32 + f.M42,
			M41 * f.M13 + M42 * f.M23 + M43 * f.M33 + f.M43,

			Determinant * f.Determinant
			);
		}
Esempio n. 5
0
		public RectangleTransformedD3D(RectangleD3D rectangle, Matrix4x3 transformation)
		{
			_rectangle = rectangle;
			_transformation = transformation;
		}
Esempio n. 6
0
			public LineShapeHitTestObject(LineShape parent, Matrix4x3 localToWorldTransformation)
				: base(parent, localToWorldTransformation)
			{
			}
Esempio n. 7
0
		/// <summary>
		/// Gets the path of the object in object world coordinates.
		/// </summary>
		/// <returns></returns>
		public override IObjectOutlineForArrangements GetObjectOutlineForArrangements(Matrix4x3 localToWorldTransformation)
		{
			return new LineShapeObjectOutline(_transformation.WithAppendedTransformation(localToWorldTransformation), Bounds);
		}
Esempio n. 8
0
		/// <summary>
		/// Returns a new matrix based on the current matrix, but onto which another transformation was prepended.
		/// </summary>
		/// <param name="l">The matrix to prepend.</param>
		/// <returns>New matrix based on the current matrix, but onto which another transformation was prepended.</returns>
		public Matrix4x4 WithPrependedTransformation(Matrix4x3 l)
		{
			return new Matrix4x4(
				l.M11 * M11 + l.M12 * M21 + l.M13 * M31, l.M11 * M12 + l.M12 * M22 + l.M13 * M32, l.M11 * M13 + l.M12 * M23 + l.M13 * M33, l.M11 * M14 + l.M12 * M24 + l.M13 * M34,
				l.M21 * M11 + l.M22 * M21 + l.M23 * M31, l.M21 * M12 + l.M22 * M22 + l.M23 * M32, l.M21 * M13 + l.M22 * M23 + l.M23 * M33, l.M21 * M14 + l.M22 * M24 + l.M23 * M34,
				l.M31 * M11 + l.M32 * M21 + l.M33 * M31, l.M31 * M12 + l.M32 * M22 + l.M33 * M32, l.M31 * M13 + l.M32 * M23 + l.M33 * M33, l.M31 * M14 + l.M32 * M24 + l.M33 * M34,
				l.M41 * M11 + l.M42 * M21 + l.M43 * M31 + M41, l.M41 * M12 + l.M42 * M22 + l.M43 * M32 + M42, l.M41 * M13 + l.M42 * M23 + l.M43 * M33 + M43, l.M41 * M14 + l.M42 * M24 + l.M43 * M34 + M44
	 );
		}
Esempio n. 9
0
			internal GraphicState(Matrix4x3 transformation, Matrix3x3 transposedInverseTransformation)
			{
				Transformation = transformation;
				TransposedInverseTransformation = transposedInverseTransformation;
			}
Esempio n. 10
0
		public override void PrependTransform(Matrix4x3 m)
		{
			_transformation.PrependTransform(m);
			_transposedInverseTransformation = _transformation.GetTransposedInverseMatrix3x3();
		}
Esempio n. 11
0
		public MultipleSingleLinesObjectOutline(double thickness1, double thickness2, IEnumerable<LineD3D> lines, Matrix4x3 localToWorldTransformation)
		{
			_thickness1By2 = thickness1 * 0.55;
			_thickness2By2 = thickness2 * 0.55;
			_lines = lines.ToArray();
			_transformation = localToWorldTransformation;
		}
Esempio n. 12
0
		public PolylineObjectOutline(double thickness1, double thickness2, IEnumerable<PointD3D> points, Matrix4x3 localToWorldTransformation)
		{
			_thickness1By2 = thickness1 * 0.55;
			_thickness2By2 = thickness2 * 0.55;
			_points = points.ToArray();
			_transformation = localToWorldTransformation;
		}
Esempio n. 13
0
		public MultiRectangularObjectOutline(IEnumerable<RectangleD3D> rectangles, Matrix4x3 transformation)
		{
			if (null == rectangles)
				throw new ArgumentNullException(nameof(rectangles));

			_rectangles = rectangles.ToArray();

			if (_rectangles.Length == 0)
				throw new ArgumentNullException(nameof(rectangles) + " yields no entries");

			_transformation = transformation;
		}
Esempio n. 14
0
		public MultipleRectangularObjectOutlines(IEnumerable<RectangularObjectOutline> outlines, Matrix4x3 localToWorldTransformation)
		{
			_outlines = outlines.ToArray();
			// Replace the original outline object with new one that contain the transformation from local (layer) to world coordinates (root layer).
			for (int i = 0; i < _outlines.Length; ++i)
			{
				if (null != _outlines[i])
					_outlines[i] = _outlines[i].WithAdditionalTransformation(localToWorldTransformation);
			}
		}
Esempio n. 15
0
		/// <summary>
		/// Creates a new camera which has the LookAtRH matrix as provided in the argument. Up and eye vector as well as eye position are calculated from the provided matrix, the target position is in such a way calculated that the distance is kept constant.
		/// </summary>
		/// <param name="l">The LookAtRH matrix. This matrix must have a determinant of 1, and each of the vectors {M11, M21, M31}, {M12, M22, M32}, {M13, M23, M33} must have a length of 1.</param>
		/// <returns>A new camera which has the LookAtRH matrix as provided in the argument. Up and eye vector as well as eye position are calculated from the provided matrix, the target position is in such a way calculated that the distance is kept constant.</returns>
		/// <exception cref="ArgumentOutOfRangeException"></exception>
		public CameraBase WithLookAtRHMatrix(Matrix4x3 l)
		{
			return WithLookAtRHMatrix(l, this.Distance);
		}
Esempio n. 16
0
		/// <summary>
		/// Returns a new <see cref="RectangularObjectOutline"/> object, at wich the provided transformation is appended.
		/// Thus, when having a <see cref="RectangularObjectOutline"/> in object coordinates, by calling this function with the current
		/// localToWorldTransformation, one gets a <see cref="RectangularObjectOutline"/> in world coordinates.
		/// </summary>
		/// <param name="transformation">The transformation to append.</param>
		/// <returns>New <see cref="RectangularObjectOutline"/> object with the provided transformation appended.</returns>
		public RectangularObjectOutline WithAdditionalTransformation(Matrix4x3 transformation)
		{
			return new RectangularObjectOutline(_rectangle, _transformation.WithAppendedTransformation(transformation));
		}
Esempio n. 17
0
		public void PrependTransform(Matrix4x3 m)
		{
			_transformation.PrependTransform(m);
		}
Esempio n. 18
0
		public void RestoreGraphicsState(object graphicsState)
		{
			var gs = graphicsState as GraphicState;
			if (null != gs)
			{
				_transformation = gs.Transformation;
			}
			else
				throw new ArgumentException(nameof(graphicsState) + " is not a valid graphic state!");
		}
Esempio n. 19
0
		public abstract void PrependTransform(Matrix4x3 m);
Esempio n. 20
0
 public RectangleTransformedD3D(RectangleD3D rectangle, Matrix4x3 transformation)
 {
     _rectangle      = rectangle;
     _transformation = transformation;
 }
Esempio n. 21
0
		/// <summary>
		/// Gets the transformation of this item plus an additional transformation. Both together transform world coordinates to page coordinates.
		/// </summary>
		/// <param name="additionalTransformation">The additional transformation matrix.</param>
		/// <returns></returns>
		public Matrix4x4 GetHitTransformationWithAdditionalTransformation(Matrix4x3 additionalTransformation)
		{
			return _hitTransformation.WithPrependedTransformation(additionalTransformation);
		}
Esempio n. 22
0
		protected override IHitTestObject GetNewHitTestObject(Matrix4x3 localToWorldTransformation)
		{
			return new LineShapeHitTestObject(this, localToWorldTransformation);
		}
Esempio n. 23
0
		/// <summary>
		/// Determines whether the specified 3D-rectangle r is hit by a ray given by x=0, y=0, z>0.
		/// </summary>
		/// <param name="r">The rectangle r.</param>
		/// <param name="rectangleToWorldTransformation">An additional transformation that transformes the given rectangle into the same coordinates as the hit data.</param>
		/// <param name="z">If there was a hit, this is the z coordinate of the hit.</param>
		/// <returns>True if the rectangle is hit by a ray given by x=0, y=0, z>0.</returns>
		public bool IsHit(RectangleD3D r, Matrix4x3 rectangleToWorldTransformation, out double z)
		{
			return IsRectangleHitByRay(r, _hitTransformation.WithPrependedTransformation(rectangleToWorldTransformation), out z);
		}
Esempio n. 24
0
			internal LineShapeObjectOutline(Matrix4x3 transformation, RectangleD3D bounds)
			{
				_transformation = transformation;
				_bounds = bounds;
			}
Esempio n. 25
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="transformation">The original hit ray matrix. Usually obtained using the mouse coordinates and the camera settings.</param>
		public HitTestPointData(Matrix4x4 transformation)
		{
			_hitTransformation = transformation;
			_worldTransformation = Matrix4x3.Identity;
		}
Esempio n. 26
0
		static Matrix4x3()
		{
			_identityMatrix = new Matrix4x3(
					1, 0, 0,
					0, 1, 0,
					0, 0, 1,
					0, 0, 0,
					1);
		}
Esempio n. 27
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="hitTransformation">The original hit ray matrix. Usually obtained using the mouse coordinates and the camera settings.</param>
		/// <param name="worldTransformation">The original world transformation.</param>
		private HitTestPointData(Matrix4x4 hitTransformation, Matrix4x3 worldTransformation)
		{
			_hitTransformation = hitTransformation;
			_worldTransformation = worldTransformation;
		}
Esempio n. 28
0
		/// <summary>
		/// Prepends a transformation matrix <paramref name="l"/> to this matrix, and returns a new matrix with the result. The original matrix is unchanged.
		/// </summary>
		/// <param name="l">The matrix to prepend.</param>
		/// <returns>A new matrix based on the existing one, but with matrix <paramref name="l"/> prepended.</returns>
		public Matrix4x3 WithPrependedTransformation(Matrix4x3 l)
		{
			return new Matrix4x3(
				l.M11 * M11 + l.M12 * M21 + l.M13 * M31,
				l.M11 * M12 + l.M12 * M22 + l.M13 * M32,
				l.M11 * M13 + l.M12 * M23 + l.M13 * M33,
				l.M21 * M11 + l.M22 * M21 + l.M23 * M31,
				l.M21 * M12 + l.M22 * M22 + l.M23 * M32,
				l.M21 * M13 + l.M22 * M23 + l.M23 * M33,
				l.M31 * M11 + l.M32 * M21 + l.M33 * M31,
				l.M31 * M12 + l.M32 * M22 + l.M33 * M32,
				l.M31 * M13 + l.M32 * M23 + l.M33 * M33,
				l.M41 * M11 + l.M42 * M21 + l.M43 * M31 + M41,
				l.M41 * M12 + l.M42 * M22 + l.M43 * M32 + M42,
				l.M41 * M13 + l.M42 * M23 + l.M43 * M33 + M43,
				l.Determinant * Determinant
				);
		}
Esempio n. 29
0
		/// <summary>
		/// Copy constructor.
		/// </summary>
		/// <param name="from">Another HitTestData object to copy from.</param>
		public HitTestPointData(HitTestPointData from)
		{
			this._hitTransformation = from._hitTransformation;
			this._worldTransformation = from._worldTransformation;
		}
Esempio n. 30
0
		/// <summary>
		/// Prepends a transformation matrix <paramref name="a"/> to this matrix.
		/// </summary>
		/// <param name="a">The matrix to prepend.</param>
		public void PrependTransform(Matrix4x3 a)
		{
			double h1, h2, h3, h4;

			h1 = M11 * a.M11 + M21 * a.M12 + M31 * a.M13;
			h2 = M11 * a.M21 + M21 * a.M22 + M31 * a.M23;
			h3 = M11 * a.M31 + M21 * a.M32 + M31 * a.M33;
			h4 = M11 * a.M41 + M21 * a.M42 + M31 * a.M43;
			M11 = h1; M21 = h2; M31 = h3; M41 += h4;

			h1 = M12 * a.M11 + M22 * a.M12 + M32 * a.M13;
			h2 = M12 * a.M21 + M22 * a.M22 + M32 * a.M23;
			h3 = M12 * a.M31 + M22 * a.M32 + M32 * a.M33;
			h4 = M12 * a.M41 + M22 * a.M42 + M32 * a.M43;
			M12 = h1; M22 = h2; M32 = h3; M42 += h4;

			h1 = M13 * a.M11 + M23 * a.M12 + M33 * a.M13;
			h2 = M13 * a.M21 + M23 * a.M22 + M33 * a.M23;
			h3 = M13 * a.M31 + M23 * a.M32 + M33 * a.M33;
			h4 = M13 * a.M41 + M23 * a.M42 + M33 * a.M43;
			M13 = h1; M23 = h2; M33 = h3; M43 += h4;

			Determinant *= a.Determinant;
		}
Esempio n. 31
0
		public HitTestPointData NewFromAdditionalTransformation(Matrix4x3 additionalTransformation)
		{
			return new HitTestPointData(this._hitTransformation.WithPrependedTransformation(additionalTransformation), this._worldTransformation.WithPrependedTransformation(additionalTransformation));
		}
Esempio n. 32
0
		/// <summary>
		/// Creates a new camera which has the LookAtRH matrix as provided in the argument. Up and eye vector as well as eye position are calculated from the provided matrix, the target position is calculated from the eye vector and the provided <paramref name="newDistance"/> value.
		/// </summary>
		/// <param name="l">The LookAtRH matrix. This matrix must have a determinant of 1, and each of the vectors {M11, M21, M31}, {M12, M22, M32}, {M13, M23, M33} must have a length of 1.</param>
		/// <param name="newDistance">The distance between camera eye and target of the new camera.</param>
		/// <returns>A new camera which has the LookAtRH matrix as provided in the argument. Up and eye vector as well as eye position are calculated from the provided matrix, the target position is calculated from the eye vector and the provided <paramref name="newDistance"/> value.</returns>
		/// <exception cref="ArgumentOutOfRangeException"></exception>
		public CameraBase WithLookAtRHMatrix(Matrix4x3 l, double newDistance)
		{
			double determinant = l.Determinant;

			if (!(determinant > 0.9 && determinant < 1.1))
				throw new ArgumentOutOfRangeException(nameof(l) + " seems not to be a LookAtRH matrix because its determinant is not 1");

			// get position
			var eyePos = new PointD3D(
			(l.M23 * l.M32 * l.M41 - l.M22 * l.M33 * l.M41 - l.M23 * l.M31 * l.M42 + l.M21 * l.M33 * l.M42 + l.M22 * l.M31 * l.M43 - l.M21 * l.M32 * l.M43) / determinant,
			(-(l.M13 * l.M32 * l.M41) + l.M12 * l.M33 * l.M41 + l.M13 * l.M31 * l.M42 - l.M11 * l.M33 * l.M42 - l.M12 * l.M31 * l.M43 + l.M11 * l.M32 * l.M43) / determinant,
			(l.M13 * l.M22 * l.M41 - l.M12 * l.M23 * l.M41 - l.M13 * l.M21 * l.M42 + l.M11 * l.M23 * l.M42 + l.M12 * l.M21 * l.M43 - l.M11 * l.M22 * l.M43) / determinant
			);

			var upVector = new VectorD3D(l.M12, l.M22, l.M32);
			var eyeVector = new VectorD3D(l.M13, l.M23, l.M33);

			return WithUpEyeTarget(upVector, eyePos, eyePos - eyeVector * newDistance);
		}
Esempio n. 33
0
		public RectangularObjectOutline(RectangleD3D rectangle, Matrix4x3 transformation)
		{
			_rectangle = rectangle;
			_transformation = transformation;
		}