BLOG.CSHARPHELPER.COM: Draw improved 3D "line segments" using WPF and XAML
Draw improved 3D "line segments" using WPF and XAML
The example Draw 3D two interlocked tetrahedrons in a cage of "line segments" using WPF and XAML shows how to draw a skinny rectangular prism to represent line segments. If you make the prisms thick enough, you can see that they don't line up well at their corners. (See the picture on the left side.)
This example uses the following AddSegment method to extend prisms slightly so segments that share an end point overlap by the size of their thickness. That makes them line up nicely. (At least when their prism sides are parallel. See the picture on the right side.) The new code is shown in blue.
If the extend parameter is true, the program creates a vector in the direction of the line segment that has length equal to half of the prism's width. It then moves the segment's end points that distance away from each other to extend the segment the correct amount.
The rest of the method is similar to the code used in the previous example.
4/14/2014 9:09 PM
BLOG.CSHARPHELPER.COM wrote:
The example Draw improved 3D "line segments" using WPF and XAML showed how to draw thin rectangular boxes to represent three-dimensional line segments. This example uses that technique to draw arrows. The following code shows the AddArrow extension method that adds an arrow to a MeshGeometry3D object. // Make an arrow. public static void AddArrow(this MeshGeometry3D mesh, Point3D point1, Point3D point2, Vector3D up, double barb_length) { // Make the shaft. AddSegment(mesh, point1, point2, 0.05, true); ...
Comments