public List <ApplicationPlaceholderObject> AnalyticalSurfaceToNative(Element2D speckleElement) { List <ApplicationPlaceholderObject> placeholderObjects = new List <ApplicationPlaceholderObject> { }; switch (speckleElement.property.type) { case Structural.PropertyType2D.Wall: Geometry.Line baseline = GetBottomLine(speckleElement.topology); double lowestElvevation = speckleElement.topology.Min(node => node.basePoint.z); double topElevation = speckleElement.topology.Max(node => node.basePoint.z); Node bottomNode = speckleElement.topology.Find(node => node.basePoint.z == lowestElvevation); Node topNode = speckleElement.topology.Find(node => node.basePoint.z == topElevation); var bottemLevel = LevelFromPoint(PointToNative(bottomNode.basePoint)); var topLevel = LevelFromPoint(PointToNative(topNode.basePoint)); RevitWall revitWall = new RevitWall(speckleElement.property.name, speckleElement.property.name, baseline, bottemLevel, topLevel); return(WallToNative(revitWall)); break; default: var polycurve = PolycurveFromTopology(speckleElement.topology); var level = LevelFromPoint(PointToNative(speckleElement.topology[0].basePoint)); RevitFloor revitFloor = new RevitFloor(speckleElement.property.name, speckleElement.property.name, polycurve, level); return(FloorToNative(revitFloor)); break; } return(placeholderObjects); }
/// <summary> /// This operation creates a new Point using the position dialog. /// </summary> /// <param name="firstPoint">The first point to be used.</param> /// <param name="secondPoint">The last point to be used.</param> /// <returns>The point between the first and the second points.</returns> public PSPoint CreatePointBetweenPoints(Geometry.Point firstPoint, Geometry.Point secondPoint) { // Create line between the two points Geometry.Line lineBetweenPoints = new Geometry.Line(firstPoint, secondPoint); // Start create point return(_powerSHAPE.ActiveModel.Points.CreatePoint(lineBetweenPoints.MidPoint)); }
/// <since>5.0</since> public bool PickFrustumTest(Geometry.Line line, out double t, out double depth, out double distance) { t = -1; depth = -1; distance = -1; IntPtr const_ptr_this = ConstPointer(); return(UnsafeNativeMethods.CRhinoPickContext_PickLine2(const_ptr_this, line.From, line.To, ref t, ref depth, ref distance)); }
/// <summary> /// Perform the 'get' operation. /// </summary> /// <param name="line"></param> /// <returns></returns> /// <since>5.1</since> public Commands.Result Get(out Geometry.Line line) { IntPtr ptr_this = NonConstPointer(); line = Geometry.Line.Unset; int rc = UnsafeNativeMethods.RHC_RhinoGetLine2(ptr_this, ref line, IntPtr.Zero); return((Commands.Result)rc); }
public static Vector3 CalculateMidpoint(Geometry.Line line) { float x = (line.end.x + line.start.x) / 2.0f; float y = 0; float z = (line.end.z + line.start.z) / 2.0f; Vector3 midpoint = new Vector3(x, y, z); return(midpoint); }
private static void Drawing_OnEndScene(EventArgs args) { if (!LoadTracker.Enabled) { return; } foreach (var item in GameObjects.EnemyHeroes) { var target = item; var histracker = TrackerHelp.Where(i => i.Unit.NetworkId == target.NetworkId).FirstOrDefault(); if (histracker != null) { if (histracker.InValidPosition.DistanceToPlayer() <= 3000) { var line = new Geometry.Line(ObjectManager.Player.Position, histracker.InValidPosition); line.Draw(System.Drawing.Color.Red); } if (histracker.ValidPosition.IsOnScreen() || histracker.InValidPosition.IsOnScreen()) { if (histracker.InValidPosition.IsOnScreen()) { var pos = Drawing.WorldToScreen(histracker.InValidPosition); Drawing.DrawText(pos.X, pos.Y, System.Drawing.Color.Yellow, target.CharacterName); Render.Circle.DrawCircle(histracker.InValidPosition, 50, System.Drawing.Color.Red); } if (histracker.ValidPosition.IsOnScreen() && histracker.ValidPosition.Distance(histracker.InValidPosition) > histracker.Unit.BoundingRadius) { var pos = Drawing.WorldToScreen(histracker.ValidPosition); Drawing.DrawText(pos.X, pos.Y, System.Drawing.Color.Yellow, target.CharacterName); Render.Circle.DrawCircle(histracker.ValidPosition, 50, System.Drawing.Color.Green); } /*if (histracker.InValidPosition.Distance(histracker.ValidPosition) > histracker.Unit.BoundingRadius) * { * var line = new Geometry.Line(histracker.InValidPosition, histracker.ValidPosition); * line.Draw(System.Drawing.Color.Blue); * }*/ /*if (histracker.InValidPosition.Distance(histracker.ValidPosition) > histracker.Unit.BoundingRadius) * { * * } * else * { * * }*/ } } } }
public bool ListContainsLine(List <Geometry.Line> list, Geometry.Line line) { for (int i = 0; i < list.Count; i++) { if (line.start == list[i].start || line.end == list[i].start) { if (line.start == list[i].end || line.end == list[i].end) { return(true); } } } return(false); }
public MainWindow() { InitializeComponent(); GenerateSpider(); Geometry.Line line = new Geometry.Line(0, 0, 1000, 1000); //GeometryVisualiserDialog.ShowDialog(line); VertexGeometry arc = new Geometry.Arc(new Circle(30, new Geometry.Vector(-50, -50))); //GeometryVisualiserDialog.ShowDialog(arc); VertexGeometryCollection coll = new VertexGeometryCollection(line, arc); GeometryVisualiserDialog.ShowDialog(coll); }
public Objects.Geometry.Line GetBottomLine(List <Node> nodes) { Objects.Geometry.Line baseLine = new Objects.Geometry.Line(); double lowest_elv = nodes.Min(nodes => nodes.basePoint.z); List <Node> nodes1 = nodes.FindAll(node => node.basePoint.z.Equals(lowest_elv)); if (nodes1.Count == 2) { var point1 = nodes1[0].basePoint; var point2 = nodes1[1].basePoint; baseLine = new Geometry.Line(point1, point2, point1.units); return(baseLine); } return(null); }
public static Geometry.Circle CalculateCircumcircle(Geometry.Triangle triangle) { Vector3[] midpoints = new Vector3[3]; Vector3[] bisectors = new Vector3[3]; Geometry.Line[] edges = new Geometry.Line[3]; for (int i = 0; i < 3; i++) { midpoints[i] = CalculateMidpoint(triangle.lines[i]); Vector3 temp = midpoints[i] - triangle.lines[i].start; bisectors[i].x = -temp.z; bisectors[i].y = 0.0f; bisectors[i].z = temp.x; } edges[0] = new Geometry.Line(midpoints[0], bisectors[0] + midpoints[0]); edges[1] = new Geometry.Line(midpoints[1], bisectors[1] + midpoints[1]); edges[2] = new Geometry.Line(midpoints[2], bisectors[2] + midpoints[2]); Vector3[] intersectionPoints = new Vector3[3]; intersectionPoints[0] = FindIntersection(edges[0], edges[1]); intersectionPoints[1] = FindIntersection(edges[1], edges[2]); intersectionPoints[2] = FindIntersection(edges[2], edges[0]); bool isCenter = (intersectionPoints[0] == intersectionPoints[1] && intersectionPoints[1] == intersectionPoints[2]); Vector3 vertexPosition = edges[0].start; Vector3 circlePosition = intersectionPoints[0]; float distanceA = Vector3.Distance(triangle.pointA, circlePosition); float distanceB = Vector3.Distance(triangle.pointB, circlePosition); float distanceC = Vector3.Distance(triangle.pointC, circlePosition); bool equidistance = (distanceA == distanceB && distanceB == distanceC); float maxDistance = Mathf.Max(distanceA, distanceB, distanceC); return(new Geometry.Circle(circlePosition, maxDistance)); }
private static void Game_OnUpdate(EventArgs args) { if (!ObjectManager.Player.HasBuff("SionR")) { return; } var obj = new GameObject(); var pos = ObjectManager.Player.Position.Extend(Game.CursorPos, 1000); Geometry.Line line = new Geometry.Line(ObjectManager.Player.Position, pos); line.Draw(Color.White, 200); foreach (var l in line.Points) { if (obj.Position.Distance(l) < 100) { Orbwalker.Attack((AIBaseClient)obj); } } }
public Objects.Geometry.Polycurve PolycurveFromTopology(List <Node> nodes) { Polycurve polycurve = new Polycurve(); foreach (int index in Enumerable.Range(0, nodes.Count)) { if (index == nodes.Count - 1) { var point1 = nodes[index].basePoint; var point2 = nodes[0].basePoint; Geometry.Line segment = new Geometry.Line(point1, point2, point1.units); polycurve.segments.Add(segment); } else { var point1 = nodes[index].basePoint; var point2 = nodes[index + 1].basePoint; Geometry.Line segment = new Geometry.Line(point1, point2, point1.units); polycurve.segments.Add(segment); } } return(polycurve); }
public static Vector3 FindIntersection(Geometry.Line A, Geometry.Line B) { float A1 = A.end.z - A.start.z; float B1 = A.start.x - A.end.x; float C1 = A1 * A.start.x + B1 * A.start.z; float A2 = B.end.z - B.start.z; float B2 = B.start.x - B.end.x; float C2 = A2 * B.start.x + B2 * B.start.z; float det = A1 * B2 - A2 * B1; if (det == 0) { return(Vector3.up); } else { float x = (B2 * C1 - B1 * C2) / det; float z = (A1 * C2 - A2 * C1) / det; return(new Vector3(x, 0, z)); } }
public GeometryVisualiserDialog(object visualise) : this() { VertexGeometryCollection geometry = new VertexGeometryCollection(); if (_StorePath.Exists) { try { Stream stream = new FileStream(_StorePath, FileMode.Open, FileAccess.Read, FileShare.Read); stream.Seek(0, SeekOrigin.Begin); IFormatter formatter = new BinaryFormatter(); formatter.Binder = new CustomSerializationBinder(); var storedGeo = formatter.Deserialize(stream) as VertexGeometryCollection; stream.Close(); if (storedGeo != null) { geometry.AddRange(storedGeo); } } catch { } } if (visualise is MeshFace) { visualise = new MeshFaceCollection((MeshFace)visualise); } //else if (visualise is Mesh) visualise = ((Mesh)visualise).Faces; if (visualise is IList <VertexGeometry> ) { geometry.TryAddRange((IList <VertexGeometry>)visualise); } else if (visualise is IList <Curve> ) { geometry.TryAddRange((IList <Curve>)visualise); } else if (visualise is IList <PlanarRegion> ) { geometry.TryAddRange((IList <PlanarRegion>)visualise); } else if (visualise is VertexGeometry) { geometry.TryAdd((VertexGeometry)visualise); } else if (visualise is MeshFaceCollection) { var faces = (MeshFaceCollection)visualise; CurveCollection edges = faces.ExtractFaceBoundaries(); foreach (var edge in edges) { var region = new PlanarRegion(edge); geometry.Add(region); region.Attributes = new GeometryAttributes(new Colour(128, 0, 255, 128)); geometry.Add(edge); edge.Attributes = new GeometryAttributes(new Colour(64, 0, 0, 0)); } } else if (visualise is IList <Vertex> ) { var verts = (IList <Vertex>)visualise; var cloud = new Cloud(verts.GetPositions()); geometry.Add(cloud); } else if (visualise is IList <Geometry.Vector> ) { var v = (IList <Geometry.Vector>)visualise; var cloud = new Cloud(v); geometry.Add(cloud); } else if (visualise is MeshDivisionEdge) { var mDE = (MeshDivisionEdge)visualise; var line = new Geometry.Line(mDE.Start, mDE.End); geometry.Add(line); if (mDE.Vertices != null && mDE.Vertices.Count > 0) { var cloud = new Cloud(mDE.Vertices.GetPositions()); geometry.Add(cloud); } } else if (visualise is IList <MeshDivisionEdge> ) { foreach (var mDC in (IList <MeshDivisionEdge>)visualise) { var mDE = (MeshDivisionEdge)visualise; var line = new Geometry.Line(mDE.Start, mDE.End); geometry.Add(line); if (mDE.Vertices != null && mDE.Vertices.Count > 0) { var cloud = new Cloud(mDE.Vertices.GetPositions()); geometry.Add(cloud); } } } else if (visualise is IWidePath) { IWidePath path = (IWidePath)visualise; AddWidePath(geometry, path); } else if (visualise is IList <IWidePath> ) { foreach (var path in (IList <IWidePath>)visualise) { AddWidePath(geometry, path); } } // TODO: Convert other types to vertexgeometry BoundingBox bBox = geometry.BoundingBox; /*MinX.Text = bBox.MinX.ToString(); * MaxX.Text = bBox.MaxX.ToString(); * MinY.Text = bBox.MinY.ToString(); * MaxY.Text = bBox.MaxY.ToString();*/ Canvas.CurveThickness = 0.005 * bBox.SizeVector.Magnitude(); Canvas.PointDiameter = 0.01 * bBox.SizeVector.Magnitude(); Canvas.DefaultBrush = new SolidColorBrush(Color.FromArgb(128, 0, 0, 0)); //Canvas.FillBrush = new SolidColorBrush(Color.FromArgb(64, 0, 0, 0)); Canvas.Geometry = geometry; /*var xDivs = bBox.X.ReasonableDivisions(10); * var yDivs = bBox.Y.ReasonableDivisions(10); * * foreach (double x in xDivs) * { * var line = new Geometry.Line(x, bBox.MinY - 10, x, bBox.MaxY + 10); * line.Attributes = new GeometryAttributes(Rendering.Colour.Green, 0.1); * Canvas.AddContents(line); * }*/ }