Reputation: 7277
I have set of points. I created strip triangles using these points.
I am using HelixToolkit to draw these rectangles. Function requires list of pointes (triangles will be made using triangle strip) and set of normal vectors. Now I need to calculate normal. What I thought that for each triangle there should be a normal. But function says that for every point there will be a normal. I used three points to calculate normal of a triangle, but how can I calculate normal of a point.
So if am using the example shown in the figure what will be normal of All points (A, B, C, D, E, F).
Here is the method which I am calling.
/// <summary>
/// Adds a triangle strip to the mesh.
/// </summary>
/// <param name="stripPositions">
/// The points of the triangle strip.
/// </param>
/// <param name="stripNormals">
/// The normal vectors of the triangle strip.
/// </param>
/// <param name="stripTextureCoordinates">
/// The texture coordinates of the triangle strip.
/// </param>
/// <remarks>
/// See http://en.wikipedia.org/wiki/Triangle_strip.
/// </remarks>
public void AddTriangleStrip(
IList<Point3D> stripPositions,
IList<Vector3D> stripNormals = null,
IList<Point> stripTextureCoordinates = null)
Here is what I have.
var points = new List<Point3D>();
// populate points.
// TODO: populate Normal for each point.
AddTriangleStrip(points, normal);
I used this method to calculate normal of a surface.
private static Vector3D CalculateNormal(Point3D firstPoint, Point3D secondPoint, Point3D thirdPoint)
{
var u = new Point3D(firstPoint.X - secondPoint.X,
firstPoint.Y - secondPoint.Y,
firstPoint.Z - secondPoint.Z);
var v = new Point3D(secondPoint.X - thirdPoint.X,
secondPoint.Y - thirdPoint.Y,
secondPoint.Z - thirdPoint.Z);
return new Vector3D(u.Y * v.Z - u.Z * v.Y, u.Z * v.X - u.X * v.Z, u.X * v.Y - u.Y * v.X);
}
Upvotes: 0
Views: 2234
Reputation: 62265
There is no such concept like a normal of Point. Normal refers to a surface and not to a point, so I presume that we are talking here about average normal of all neighbour faces of a given point .
For this, you should know somehow from given point all connected to it faces. For every face calculate its normal and make an average of them
Hope this helps.
Upvotes: 1