private static void ExportEdgeToSVG(System.IO.TextWriter writer, ISurface surface, Topology.FaceEdge edge, Topology.FaceEdge nearVertexFaceEdge, Topology.FaceEdge farVertexFaceEdge, Func <Vector3, Vector2> flatten, IVertexAttribute <Vector3> vertexPositions, string arrowFormat, string edgeIndexFormat, SVGStyle style, string additionalClasses) { var p0 = vertexPositions[nearVertexFaceEdge]; var p1 = vertexPositions[farVertexFaceEdge]; var n0 = surface.GetNormal(p0); var n1 = surface.GetNormal(p1); var edgeDirection = (p1 - p0).normalized; var edgeNormal0 = (n0 + n1).normalized; var edgeNormal1 = Vector3.Cross(edgeDirection, edgeNormal0); var offset0 = edgeDirection * (style.vertexCircleRadius + style.edgeSeparation); var offset1 = edgeNormal1 * style.edgeSeparation * 0.5f; var offset2 = -edgeDirection * style.edgeArrowOffset.x + edgeNormal1 * style.edgeArrowOffset.y; Vector2 arrow0 = flatten(p0 + offset0 + offset1); Vector2 arrow1 = flatten(p1 - offset0 + offset1); Vector2 arrow2 = flatten(p1 - offset0 + offset1 + offset2); writer.WriteLine(arrowFormat, arrow0.x, arrow0.y, arrow1.x, arrow1.y, arrow2.x, arrow2.y, additionalClasses); if (style.showEdgeIndices) { var edgeCenter = flatten((p0 + p1) * 0.5f + edgeNormal1 * (style.edgeSeparation * 0.5f + style.edgeIndexOffset)); writer.WriteLine(edgeIndexFormat, edgeCenter.x, edgeCenter.y, edge.index, additionalClasses); } }
/// <summary> /// Calculates vertex normals using the surface normal reported by the given surface based on the position of each vertex. /// </summary> /// <param name="vertices">The collection of vertices whose normals are to be calculated.</param> /// <param name="surface">The surface descriptor that will provide surface normal information.</param> /// <param name="vertexPositions">The positions of the vertices.</param> /// <param name="vertexNormals">A pre-allocated collection in which the vertex normals will be stored.</param> /// <returns>The surface normals of the vertices.</returns> public static IVertexAttribute <Vector3> CalculateVertexNormalsFromSurface(Topology.VerticesIndexer vertices, ISurface surface, IVertexAttribute <Vector3> vertexPositions, IVertexAttribute <Vector3> vertexNormals) { foreach (var vertex in vertices) { vertexNormals[vertex] = surface.GetNormal(vertexPositions[vertex]); } return(vertexNormals); }
public Intersection(double distance, ISurface surface, Ray ray) { Distance = distance; Surface = surface; Ray = ray; Position = ray.GetPosition(distance); EyeVector = -ray.Direction; var candidateNormalVector = surface.GetNormal(Position); IsInsideSurface = candidateNormalVector * EyeVector < 0; NormalVector = IsInsideSurface ? -candidateNormalVector : candidateNormalVector; OverPosition = Position + (NormalVector * Constants.Epsilon); }
public GeoVector GetNormal(GeoPoint2D uv) { return(original.GetNormal(unscale * uv)); }
/// <summary> /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.PointAt (GeoPoint2D)"/> /// </summary> /// <param name="uv"></param> /// <returns></returns> public override GeoPoint PointAt(GeoPoint2D uv) { return(baseSurface.PointAt(uv) + offset * baseSurface.GetNormal(uv).Normalized); }