當前位置: 首頁>>代碼示例>>C#>>正文


C# Point3D.TransformToBounds方法代碼示例

本文整理匯總了C#中System.Windows.Media.Media3D.Point3D.TransformToBounds方法的典型用法代碼示例。如果您正苦於以下問題:C# Point3D.TransformToBounds方法的具體用法?C# Point3D.TransformToBounds怎麽用?C# Point3D.TransformToBounds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Media.Media3D.Point3D的用法示例。


在下文中一共展示了Point3D.TransformToBounds方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DrawLine

		protected void DrawLine(Point3D point)
		{
			// point was in cube [0..1]x[0..1]x[0..1], we are transforming it 
			// to cube [0..width]x[0..height]x[0..depth]

			Point3D start = point.TransformToBounds(bounds);

			int maxLength = 10 * Math.Max(width, Math.Max(height, depth));
			const int maxIterations = 400;
			Size3D boundsSize = new Size3D(1.0 / width, 1.0 / height, 1.0 / depth);

			Action<double, List<Point3D>> pointTracking = (direction, track) =>
			{
				var position01 = point;
				double length = 0;
				int i = 0;
				do
				{
					var K1 = fieldWrapper.GetVector(position01).DecreaseLength(boundsSize);
					var K2 = fieldWrapper.GetVector(position01 + (K1 / 2)).DecreaseLength(boundsSize);
					var K3 = fieldWrapper.GetVector(position01 + (K2 / 2)).DecreaseLength(boundsSize);
					var K4 = fieldWrapper.GetVector(position01 + K3).DecreaseLength(boundsSize);

					var shift = ((K1 + 2 * K2 + 2 * K3 + K4) / 6);
					if (shift.X.IsNaN() || shift.Y.IsNaN() || shift.Z.IsNaN())
						break;

					var next = position01 + direction * shift;
					Point3D viewportPoint = position01.TransformToBounds(bounds);
					track.Add(viewportPoint);

					position01 = next;
					length += shift.Length;
					i++;
				} while (length < maxLength && i < maxIterations);
			};

			var forwardTrack = new List<Point3D>();
			forwardTrack.Add(start);
			pointTracking(+1, forwardTrack);
			if (forwardTrack.Count > 1)
			{
				var forwardLine = CreatePolyline(forwardTrack, start);
				Children.Add(forwardLine);
			}

			var backwardTrack = new List<Point3D>();
			backwardTrack.Add(start);
			pointTracking(-1, backwardTrack);
			if (backwardTrack.Count > 1)
			{
				var backwardLine = CreatePolyline(backwardTrack, start);
				Children.Add(backwardLine);
			}
		}
開發者ID:XiBeichuan,項目名稱:hydronumerics,代碼行數:55,代碼來源:StreamlineChartBase3D.cs


注:本文中的System.Windows.Media.Media3D.Point3D.TransformToBounds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。