private static GameObject InitializeSweeplineObject(Sweepline sweepline) { var vertices = SweeplineVertices(sweepline); var gameObject = DrawingUtilities.CreateLineObject("Sweepline", vertices, "SweeplineMaterial"); return(gameObject); }
public void Update() { var mesh = _gameObject.GetComponent <MeshFilter>().mesh; var vertices = SweeplineVertices(_sweepline); DrawingUtilities.UpdateLineObject(mesh, vertices); }
private static IEnumerable <Vector3> ArcVertices(IArc arc, IArc nextArc, Sweepline sweepline) { if (arc.LeftNeighbour == arc.Site) { var azimuths = DrawingUtilities.AnglesInRange(0, 2 * Mathf.PI, NumberOfVerticesPerArc); var vertices = azimuths.Select(azimuth => PointOnEllipse(arc, azimuth, sweepline)).ToList(); return(vertices); } else if (Mathf.Approximately((float)arc.Site.Priority, (float)sweepline.Priority)) { var intersection = arc.PointOfIntersection(sweepline).ToUnityVector3(); var site = arc.Site.Position.ToUnityVector3(); var downArc = DrawingUtilities.VerticesOnGeodesic(intersection, site, NumberOfVerticesPerArc); var upArc = DrawingUtilities.VerticesOnGeodesic(site, intersection, NumberOfVerticesPerArc); var vertices = downArc.Concat(upArc); return(vertices); } else { var leftLimit = DrawingUtilities.AzimuthOf(arc.LeftIntersection(sweepline).ToUnityVector3()); var rightLimit = DrawingUtilities.AzimuthOf(nextArc.LeftIntersection(sweepline).ToUnityVector3()); var azimuths = DrawingUtilities.AnglesInRange(leftLimit, rightLimit, NumberOfVerticesPerArc); var vertices = azimuths.Select(azimuth => PointOnEllipse(arc, azimuth, sweepline)).ToList(); return(vertices); } }
private static GameObject InitializeBeachlineObject(Beachline beachline) { var vertices = BeachlineVertices(beachline); var gameObject = DrawingUtilities.CreateLineObject("Beachline", vertices, "BeachlineMaterial"); return(gameObject); }
private static GameObject DrawEdgeList(List <Vertex> vectorsInEdgeList) { var vertices = VerticesInEdgeList(vectorsInEdgeList); var gameObject = DrawingUtilities.CreateLineObject("Edge list", vertices, "EdgeMaterial"); return(gameObject); }
private Vector3[] CircleEventVertices(CircleEvent circle) { var angles = DrawingUtilities.AnglesInRange(0, 2 * Mathf.PI, NumberOfVerticesPerCircle); var points = angles.Select(angle => VertexOfCircleEvent(circle, angle)).ToArray(); return(points); }
private static Vector3[] SweeplineVertices(Sweepline sweepline) { if (Math.Abs(sweepline.Z) >= 1) { return(new Vector3[0]); } var azimuths = DrawingUtilities.AnglesInRange(0, 2 * Mathf.PI, NumberOfVertices); var vertices = azimuths.Select(azimuth => VertexOnSweepline(sweepline, azimuth)).ToArray(); return(vertices); }
private static GameObject DrawLabelsAtColatitude(float colatitude) { var azimuths = DrawingUtilities.AnglesInRange(0, 2 * Mathf.PI, 36); var labels = azimuths.Take(36).Select(azimuth => DrawLabel(colatitude, azimuth)); var parentObject = new GameObject("Latitude Labels " + Mathf.Rad2Deg * colatitude); foreach (var label in labels) { label.transform.parent = parentObject.transform; } return(parentObject); }
private static IEnumerable <Vector3> VerticesInEdge(Vertex origin, Vertex destination) { var originVector = origin.Position.ToUnityVector3(); var destinationVector = destination.Position.ToUnityVector3(); if (originVector == destinationVector || Vector3.Cross(originVector, destinationVector) != new Vector3(0, 0, 0)) { return(DrawingUtilities.VerticesOnGeodesic(originVector, destinationVector, NumberOfVerticesPerEdge)); } else { var commonSites = origin.Sites.Intersect(destination.Sites).ToList(); var normal = -(commonSites.First().Position.ToUnityVector3() - commonSites.Last().Position.ToUnityVector3()).normalized; return(DrawingUtilities.VerticesOnHalfOfGreatCircle(originVector, normal, NumberOfVerticesPerEdge)); } }
private static GameObject DrawLongitude(float azimuth) { var azimuths = DrawingUtilities.AnglesInRange(0, Mathf.PI, NumberOfPointsPerLongitude); var vertices = azimuths.Select( colatitude => DrawingUtilities.CreateVectorAt(colatitude, azimuth)) .ToArray(); var longitudeObject = DrawingUtilities.CreateLineObject( "Longitude " + Mathf.Rad2Deg * azimuth, vertices, "Boundaries"); return(longitudeObject); }
public void Update() { foreach (var arcAndEdgeList in _arcToEdges) { var arc = arcAndEdgeList.Key; var edgeList = arcAndEdgeList.Value.ToList(); if (!_edgeListObjects.ContainsKey(arc)) { var edgeListObject = DrawEdgeList(edgeList); edgeListObject.transform.parent = _parentObject.transform; _edgeListObjects.Add(arc, edgeListObject); } else { var newVertices = VerticesInEdgeList(edgeList); var mesh = _edgeListObjects[arc].GetComponent <MeshFilter>().mesh; DrawingUtilities.UpdateLineObject(mesh, newVertices); } } }
public void Update() { var newCircleEvents = _circleEvents.ToArray().Except(_gameObjects.Keys); foreach (var circleEvent in newCircleEvents) { var vertices = CircleEventVertices(circleEvent); var gameObject = DrawingUtilities.CreateLineObject("Circle " + circleEvent, vertices, "CircleEventMaterial"); gameObject.transform.parent = _parentObject.transform; _gameObjects.Add(circleEvent, gameObject); } var removedCircles = _gameObjects.Keys.Except(_circleEvents.ToArray()).ToList(); foreach (var circleEvent in removedCircles) { var gameObject = _gameObjects[circleEvent]; _gameObjects.Remove(circleEvent); Object.Destroy(gameObject); } }
private static GameObject DrawLabel(float colatitude, float azimuth) { var text = String.Format("{0,3:N0} {1,3:N0}", Mathf.Rad2Deg * colatitude, Mathf.Rad2Deg * azimuth); var labelObject = new GameObject("Label " + text); var normal = DrawingUtilities.CreateVectorAt(colatitude, azimuth); var localEast = Vector3.Cross(normal, new Vector3(0, 0, 1)); var localNorth = Vector3.Cross(localEast, normal); labelObject.transform.position = normal; labelObject.transform.rotation = Quaternion.LookRotation(-normal, localNorth); var textMesh = labelObject.AddComponent <TextMesh>(); textMesh.text = text; textMesh.font = Resources.Load("ARIAL", typeof(Font)) as Font; textMesh.renderer.material = Resources.Load("OneSidedMaterial", typeof(Material)) as Material; textMesh.characterSize = 0.005f; textMesh.anchor = TextAnchor.UpperCenter; return(labelObject); }