/// <summary> /// Tries to create offset entity for selected entity at the selected location (offset distance) and side. /// </summary> private void CreateOffsetEntity() { if (selEntity != null && selEntity is ICurve) { #if !NURBS if (selEntity is Ellipse || selEntity is EllipticalArc) { return; } #endif if (points.Count == 0) { renderContext.EnableXOR(false); DrawText(mouseLocation.X, (int)Size.Height - mouseLocation.Y + 10, "Side to offset", new Font("Tahoma", 8.25f), DrawingColor, ContentAlignment.BottomLeft); return; } ICurve selCurve = selEntity as ICurve; double t; bool success = selCurve.Project(points[0], out t); Point3D projectedPt = selCurve.PointAt(t); double offsetDist = projectedPt.DistanceTo(points[0]); ICurve offsetCurve = selCurve.Offset(offsetDist, Vector3D.AxisZ, 0.01, true); success = offsetCurve.Project(points[0], out t); projectedPt = offsetCurve.PointAt(t); if (projectedPt.DistanceTo(points[0]) > 1e-3) { offsetCurve = selCurve.Offset(-offsetDist, Vector3D.AxisZ, 0.01, true); } AddAndRefresh((Entity)offsetCurve, ActiveLayerName); } }
private bool CheckBallTouch(Skeleton skeleton) { double radius = this.ball.Radius; Point3D center = this.ball.Center; Joint leftHand = skeleton.Joints[JointType.HandLeft]; Joint rightHand = skeleton.Joints[JointType.HandRight]; if (leftHand.TrackingState == JointTrackingState.NotTracked && rightHand.TrackingState == JointTrackingState.NotTracked) { return(false); } Point3D leftHandPoint = this.SkeletonPointTo3D(leftHand.Position); Point3D rightHandPoint = this.SkeletonPointTo3D(rightHand.Position); double leftHandDist = center.DistanceTo(this.SkeletonPointTo3D(leftHand.Position)); double rightHandDist = center.DistanceTo(this.SkeletonPointTo3D(rightHand.Position)); double left = this.CalBallDist(center, this.SkeletonPointTo3D(leftHand.Position)); double right = this.CalBallDist(center, this.SkeletonPointTo3D(rightHand.Position)); //this.DataLogWindow.Text = right.ToString(); return(left < (radius + 0.3) || right < (radius + 0.3)); }
private void GetWalls(ReadAutodesk CadReader) { Walls = new List <Wall>(); List <List <Point3D> > lstMidPoints = new List <List <Point3D> >(); List <double> lstThickness = new List <double>(); List <Line> lstWallLines = CadHelper.LinesGetByLayerName(CadReader, CadLayerName.Wall); List <List <Line> > lstWalls = new List <List <Line> >(); for (int i = 0; i < lstWallLines.Count; i++) { Line parallel = lstWallLines[i].LineGetNearestParallel(lstWallLines.ToArray()); if (parallel != null && (lstWallLines[i].Length() > parallel.Length())) {//Exclude Lines from list lstWalls.Add(new List <Line> { lstWallLines[i], parallel }); lstThickness.Add(MathHelper.DistanceBetweenTwoParallels(lstWallLines[i], parallel)); lstWallLines.IndexOf(parallel); } } foreach (List <Line> lstParallels in lstWalls) { Point3D stPt1 = lstParallels[0].StartPoint; Point3D stPt2 = lstParallels[1].StartPoint; Point3D endPt1 = lstParallels[0].EndPoint; Point3D endPt2 = lstParallels[1].EndPoint; Point3D midStart = MathHelper.MidPoint3D(stPt1, stPt2); midStart.Z = Level - Slabs[0].Thickness * 1000; Point3D midEnd = MathHelper.MidPoint3D(endPt1, endPt2); midEnd.Z = Level - Slabs[0].Thickness * 1000; if (stPt1.DistanceTo(stPt2) < stPt1.DistanceTo(endPt2)) { lstMidPoints.Add(new List <Point3D> { midStart, midEnd }); } else { lstMidPoints.Add(new List <Point3D> { midEnd, midStart }); } } for (int i = 0; i < lstMidPoints.Count; i++) { Walls.Add(new Wall(lstThickness[i], lstMidPoints[i][0], lstMidPoints[i][1])); } }
private Tuple <Surface, Surface> GetOuterInnerSurfaces(List <Surface> surfs, Point3D origin) { Surface outer = null; Surface inner = null; foreach (var surf in surfs) { if (outer == null && inner == null) { outer = inner = surf; } else { outer.ClosestPointTo(origin, out var farthest); inner.ClosestPointTo(origin, out var closest); surf.ClosestPointTo(origin, out var candidate); var candDist = origin.DistanceTo(candidate); if (candDist > origin.DistanceTo(farthest)) { outer = surf; } if (candDist < origin.DistanceTo(closest)) { inner = surf; } } } return(new Tuple <Surface, Surface>(inner, outer)); }
/// <summary> /// Check whether we reached the end of a straight segment /// </summary> protected void CheckStraightEnd() { var currentPoint = new Point3D(_x, _y, 0, CoordinateUnit.metric); // At the last straight segment, quit the optimisation when we reach the endpoint if (_segmentIndex == _numberOfSegments) { if (currentPoint.DistanceTo(_segmentStartPoint) >= _endPoint.DistanceTo(_segmentStartPoint)) { Log("Reached end of segment" + _segmentIndex + " (straight) X:" + _x + " Y:" + _y + " Heading:" + _heading * 180 / Math.PI); _vertical_state = VERTICAL_STATE.END; } } else { // At the second last straight segment, // continue flying as long as we cannot reach the endpoint with a minimum radius turn in less than a 180degree turn if (_segmentIndex == _numberOfSegments - 2 && currentPoint.DistanceTo(_endPoint) / 2 < _aircraft.MinimumTurnRadius(_aircraft.VMax)) { Log("Continue X:" + _x); return; } // Switch from flying straight to a turn if we reach beyond the given segment length if (currentPoint.DistanceTo(_segmentStartPoint) >= Interpolate(0, MAX_SEGMENT_LENGTH, Setting(2))) { Log("Reached end of segment" + _segmentIndex + " (straight) X:" + _x + " Y:" + _y + " Heading:" + _heading * 180 / Math.PI); _horizontal_state = HORIZONTAL_STATE.TURN; _segmentStartHeading = _heading; _segmentIndex++; } } }
private double CalAngle(Point3D left, Point3D center, Point3D right) { double sideL = left.DistanceTo(center); double sideR = right.DistanceTo(center); double sideC = left.DistanceTo(right); return(Math.Acos((sideL * sideL + sideR * sideR - sideC * sideC) / (2 * sideL * sideR)) * 180 / Math.PI); }
public RectangleUI(Rectangle rectangle) : base(rectangle) { Rectangle = rectangle; var rect = new RectangleVisual3D(); double angle = GetAngleABC(rectangle.Vertices[0].Point, rectangle.Vertices[1].Point, rectangle.Vertices[2].Point); Point3D diagonalPoint, widthPoint, lengthPoint; Point3D basePoint = rectangle.Vertices[0].Point; if (IsDoubleEqual(90, angle)) { //Vertice[0] and Vertice[2] - diagonal diagonalPoint = rectangle.Vertices[2].Point; widthPoint = rectangle.Vertices[3].Point; lengthPoint = rectangle.Vertices[1].Point; } else { //Vertice[0] and Vertice[3] - diagonal diagonalPoint = rectangle.Vertices[3].Point; widthPoint = rectangle.Vertices[2].Point; lengthPoint = rectangle.Vertices[1].Point; } diagonalPoint = diagonalPoint.Multiply(SCALE_FACTOR); widthPoint = widthPoint.Multiply(SCALE_FACTOR); lengthPoint = lengthPoint.Multiply(SCALE_FACTOR); basePoint = basePoint.Multiply(SCALE_FACTOR); rect.LengthDirection = lengthPoint - basePoint; var widthDirection = widthPoint - basePoint; //check if it is really a rectangle if (!(IsDoubleEqual(Vector3D.DotProduct(widthDirection, rect.LengthDirection), 0) && IsDoubleEqual(Vector3D.DotProduct(rect.LengthDirection, lengthPoint - diagonalPoint), 0) && IsDoubleEqual(Vector3D.DotProduct(widthDirection, widthPoint - diagonalPoint), 0))) { throw new NotRectangleException($"Прямоугольник №{rectangle.Number}: четыре точки №{rectangle.Vertices[0].Number}, " + $"№{rectangle.Vertices[1].Number}, " + $"№{rectangle.Vertices[2].Number}, " + $"№{rectangle.Vertices[3].Number}, " + $"не формируют прямоугльник"); } rect.Normal = Vector3D.CrossProduct(rect.LengthDirection, widthDirection); rect.Origin = new Point3D((basePoint.X + diagonalPoint.X) / 2, (basePoint.Y + diagonalPoint.Y) / 2, (basePoint.Z + diagonalPoint.Z) / 2); rect.Width = basePoint.DistanceTo(widthPoint); rect.Length = basePoint.DistanceTo(lengthPoint); VisualElement = rect; Material.Children.Add(RectangleBaseMaterial); Title = "Прямоугольник №" + rectangle.Number; }
/// <summary> /// Gets the distance from the camera for the specified visual. /// </summary> /// <param name="c"> /// The visual. /// </param> /// <param name="cameraPos"> /// The camera position. /// </param> /// <param name="transform"> /// The total transform of the visual. /// </param> /// <returns> /// The camera distance. /// </returns> private double GetCameraDistance(Visual3D c, Point3D cameraPos, Transform3D transform) { var bounds = Visual3DHelper.FindBounds(c, transform); switch (this.Method) { case SortingMethod.BoundingBoxCenter: var mid = new Point3D( bounds.X + bounds.SizeX * 0.5, bounds.Y + bounds.SizeY * 0.5, bounds.Z + bounds.SizeZ * 0.5); return((mid - cameraPos).LengthSquared); case SortingMethod.BoundingBoxCorners: double d = double.MaxValue; d = Math.Min(d, cameraPos.DistanceTo(new Point3D(bounds.X, bounds.Y, bounds.Z))); d = Math.Min(d, cameraPos.DistanceTo(new Point3D(bounds.X + bounds.SizeX, bounds.Y, bounds.Z))); d = Math.Min( d, cameraPos.DistanceTo(new Point3D(bounds.X + bounds.SizeX, bounds.Y + bounds.SizeY, bounds.Z))); d = Math.Min(d, cameraPos.DistanceTo(new Point3D(bounds.X, bounds.Y + bounds.SizeY, bounds.Z))); d = Math.Min(d, cameraPos.DistanceTo(new Point3D(bounds.X, bounds.Y, bounds.Z + bounds.SizeZ))); d = Math.Min( d, cameraPos.DistanceTo(new Point3D(bounds.X + bounds.SizeX, bounds.Y, bounds.Z + bounds.SizeZ))); d = Math.Min( d, cameraPos.DistanceTo( new Point3D(bounds.X + bounds.SizeX, bounds.Y + bounds.SizeY, bounds.Z + bounds.SizeZ))); d = Math.Min( d, cameraPos.DistanceTo(new Point3D(bounds.X, bounds.Y + bounds.SizeY, bounds.Z + bounds.SizeZ))); return(d); default: var boundingSphere = BoundingSphere.CreateFromRect3D(bounds); return(boundingSphere.DistanceFrom(cameraPos)); } }
/// <summary> /// Create a Trajectory object with the data found in the given file /// </summary> /// <param name="filepath">the file of which the data should be read</param> /// <returns>a Trajectory object</returns> public Trajectory CreateTrajectoryFromFile(string filepath) { readFromFile(filepath); double t = 0; double previousV = 0; Point3D previousPoint = null; foreach (double[] row in _trackData) { if (row.Length == 0) { continue; } var currentPoint = new Point3D(row[0], row[1], row[2], CoordinateUnits); var metricPoint = currentPoint.ConvertTo(CoordinateUnit.metric); var currentV = row[3]; if (previousPoint != null) { t += previousPoint.DistanceTo(metricPoint) / ((currentV + previousV) / 2); } _trajectoryGenerator.AddDatapoint(metricPoint.X, metricPoint.Y, metricPoint.Z, row[3], row[4], t); previousPoint = currentPoint; previousV = currentV; } Trajectory trajectory = _trajectoryGenerator.GenerateTrajectory(); return(trajectory); }
internal void ComputeFixedPoints() { double min = 10000000; double cur = -10000000; int iMin = -1; foreach (double[] FixPoint in FixedPoints) { min = 10000000; cur = -10000000; Point3D RefPt = new Point3D(FixPoint); for (int i = 0; i < Vertices.Count; i++) { Point3D CurPt = new Point3D(Vertices[i]); cur = RefPt.DistanceTo(CurPt); if (cur < min) { min = cur; iMin = i; } } IndiceOfFixedPoints.Add(iMin); } IndiceOfFixedPoints = IndiceOfFixedPoints.Distinct().ToList(); OneIndFix = IndiceOfFixedPoints[0]; OnePointFix = new Point3D(new double[] { Vertices[OneIndFix][0], Vertices[OneIndFix][1], Vertices[OneIndFix][2] }); }
// Method for elliptical arc extension private bool ExtendEllipticalArc(ICurve ellipticalArcCurve, ICurve boundary, bool start) { EllipticalArc selEllipseArc = ellipticalArcCurve as EllipticalArc; Ellipse tempEllipse = new Ellipse(selEllipseArc.Plane, selEllipseArc.Center, selEllipseArc.RadiusX, selEllipseArc.RadiusY); #if NURBS Point3D[] intersetionPoints = Curve.Intersection(boundary, tempEllipse); if (intersetionPoints.Length == 0) { intersetionPoints = Curve.Intersection(GetExtendedBoundary(boundary), tempEllipse); } EllipticalArc newArc = null; if (intersetionPoints.Length > 0) { Plane arcPlane = selEllipseArc.Plane; if (start) { Point3D intPoint = GetClosestPoint(selEllipseArc.StartPoint, intersetionPoints); newArc = new EllipticalArc(arcPlane, selEllipseArc.Center, selEllipseArc.RadiusX, selEllipseArc.RadiusY, selEllipseArc.EndPoint, intPoint, false); // If start point is not on the new arc, flip needed double t; newArc.ClosestPointTo(selEllipseArc.StartPoint, out t); Point3D projPt = newArc.PointAt(t); if (projPt.DistanceTo(selEllipseArc.StartPoint) > 0.1) { newArc = new EllipticalArc(arcPlane, selEllipseArc.Center, selEllipseArc.RadiusX, selEllipseArc.RadiusY, selEllipseArc.EndPoint, intPoint, true); } AddAndRefresh(newArc, ((Entity)ellipticalArcCurve).LayerName); } else { Point3D intPoint = GetClosestPoint(selEllipseArc.EndPoint, intersetionPoints); newArc = new EllipticalArc(arcPlane, selEllipseArc.Center, selEllipseArc.RadiusX, selEllipseArc.RadiusY, selEllipseArc.StartPoint, intPoint, false); // If end point is not on the new arc, flip needed double t; newArc.ClosestPointTo(selEllipseArc.EndPoint, out t); Point3D projPt = newArc.PointAt(t); if (projPt.DistanceTo(selEllipseArc.EndPoint) > 0.1) { newArc = new EllipticalArc(arcPlane, selEllipseArc.Center, selEllipseArc.RadiusX, selEllipseArc.RadiusY, selEllipseArc.StartPoint, intPoint, true); } } if (newArc != null) { AddAndRefresh(newArc, ((Entity)ellipticalArcCurve).LayerName); return(true); } } #endif return(false); }
public void GetNearest_PointOnRay() { var ray = new Ray3D(new Point3D(0, 0, 0), new Vector3D(1, 2, 3)); var p0 = new Point3D(0.1, 0.2, 0.3); var p = ray.GetNearest(p0); Assert.AreEqual(0, p0.DistanceTo(p), 1e-12); }
public void PlaneIntersection_RayThroughPlaneOrigin() { var ray = new Ray3D(new Point3D(1, 2, 3), new Vector3D(-1, -2, -3)); Point3D p; Assert.IsTrue(ray.PlaneIntersection(new Point3D(0, 0, 0), new Vector3D(1, 1, 1), out p)); var pe = new Point3D(0, 0, 0); Assert.AreEqual(0, pe.DistanceTo(p), 1e-12); }
static void Main() { Console.Write("Enter x: "); int x = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter y: "); int y = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter z: "); int z = Convert.ToInt32(Console.ReadLine()); Point3D p = new Point3D(x, y, z); Console.WriteLine("P = " + p); Console.WriteLine(p.DistanceTo(new Point3D(1, 0, -1))); }
void OnTrackerDown(object sender, NodeTrackerEventArgs e) { Point3D pnt = new Point3D(e.DeltaX, e.DeltaY, e.DeltaZ); for (iHit = 0; iHit < Line.Count; ++iHit) { if (pnt.DistanceTo(Line[iHit]) < radius) { break; } } if( Line.Count == 0 || iHit == Line.Count) { Line.Add(new Point3D(e.DeltaX, e.DeltaY, e.DeltaZ)); } Update(); }
// Draws interactive elliptical arc // Inputs - Ellipse center, End of first axis, End of second axis, Start and End point private void DrawInteractiveEllipticalArc() { Point3D center = points[0]; if (points.Count <= 3) { DrawInteractiveEllipse(); } ScreenToPlane(mouseLocation, plane, out current); if (points.Count == 3) // ellipse completed, ask user to select start point { //start position line renderContext.DrawLine(WorldToScreen(center), WorldToScreen(points[1])); //current position line renderContext.DrawLine(WorldToScreen(center), WorldToScreen(current)); //arc portion radius = center.DistanceTo(points[1]); radiusY = points[2].DistanceTo(new Segment2D(center, points[1])); if (radius > 1e-3 && radiusY > 1e-3) { DrawPositionMark(points[0]); drawingPlane = GetPlane(points[1]); Vector2D v1 = new Vector2D(center, points[1]); v1.Normalize(); Vector2D v2 = new Vector2D(center, current); v2.Normalize(); arcSpanAngle = Vector2D.SignedAngleBetween(v1, v2); if (Math.Abs(arcSpanAngle) > 1e-3) { EllipticalArc tempArc = new EllipticalArc(drawingPlane, drawingPlane.Origin, radius, radiusY, 0, arcSpanAngle, true); Draw(tempArc); } } } }
public void ConvertLatLongCustom() { int referenceRdX = 155000; int referenceRdY = 463000; double referenceWgs84X = 52.15517; double referenceWgs84Y = 5.387206; x = 122202; y = 487250; var refPoint = new Point3D(referenceRdX, referenceRdY, 0, CoordinateUnit.metric); var conPoint = new Point3D(x, y, 0, CoordinateUnit.metric); double heading = refPoint.HeadingTo(conPoint); var refGeoPoint = new GeoPoint3D(referenceWgs84Y, referenceWgs84X, 0); var conGeoPoint = refGeoPoint.MoveInDirection(conPoint.DistanceTo(refPoint), heading); Assert.AreEqual(52.37214, conGeoPoint.Latitude, 0.001); Assert.AreEqual(4.905598, conGeoPoint.Longitude, 0.001); }
public static Frame Create(Region crossSection, Point3D startPoint, Point3D endPoint) { crossSection.Regen(0.0); Point3D bboxMid = (crossSection.BoxMax + crossSection.BoxMin) / 2.0; crossSection.Translate(-bboxMid.X, -bboxMid.Y, bboxMid.Z); Frame profile = crossSection.ExtrudeAsSolid <Frame>(Vector3D.AxisZ * startPoint.DistanceTo(endPoint), 0.1); profile._crossSection = crossSection; profile._startPoint = new PointT(startPoint); profile._endPoint = new PointT(endPoint); profile.Init(); profile.TransformBy(profile.Position.GetCurrentTData()); return(profile); }
static void Main() { double x, y, z; Console.Write("Enter X: "); x = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter Y: "); y = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter Z: "); z = Convert.ToDouble(Console.ReadLine()); Point3D p = new Point3D(x, y, z); Console.WriteLine("P = " + p); Console.WriteLine(p.DistanceTo(new Point3D(1, 0, -1))); p.Z += 5; Console.WriteLine("P(z incremented) = " + p); }
public static void Main() { double x, y, z; Console.Write("Enter X: "); x = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter Y: "); y = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter Z: "); z = Convert.ToDouble(Console.ReadLine()); Point3D p = new Point3D(x, y, z); Console.WriteLine("P = " + p.ToString()); Console.WriteLine("P = " + p); Console.WriteLine("Distance to (1,0,-1) = " + p.DistanceTo(new Point3D(1, 0, -1))); }
public void ResetCamera(CameraPositionEnum cameraPosition, bool lockZoom = false) { if (cameraPosition == CameraPositionEnum.Current) { cameraPosition = _CurrentCameraPosition; } Viewport.FixedRotationPoint = new Point3D(0f, 0f, _modelHeightPosition / 2f); double dirMult = cameraPosition == CameraPositionEnum.Back || cameraPosition == CameraPositionEnum.OtherSide ? -1 : 1; switch (cameraPosition) { default: case CameraPositionEnum.Default: Viewport.FixedRotationPoint = new Point3D(0f, 0f, _modelHeightPosition / 5f); Viewport.Camera.AnimateTo(_modelCameraPosition, new Vector3D(-1, 1, -1), new Vector3D(0, 0, 1), 500d); break; case CameraPositionEnum.Up: Viewport.Camera.AnimateTo(new Point3D(0, 0, _modelCameraPosition.Z * 2), new Vector3D(_CurrentCameraPosition == CameraPositionEnum.Front ? -0.01 * dirMult : 0, _CurrentCameraPosition != CameraPositionEnum.Front ? -0.01 * dirMult : 0, -1), new Vector3D(0, 0, 1f), 500d); break; case CameraPositionEnum.Front: case CameraPositionEnum.Back: Viewport.Camera.AnimateTo(new Point3D(0, _modelCameraPosition.Y * 2 * dirMult, _modelHeightPosition / 2d), new Vector3D(0, 1 * dirMult, 0), new Vector3D(0, 0, 1f), 500d); break; case CameraPositionEnum.Side: case CameraPositionEnum.OtherSide: Viewport.Camera.AnimateTo(new Point3D(_modelCameraPosition.X * 2 * dirMult, 0, _modelHeightPosition / 2d), new Vector3D(-1 * dirMult, 0, 0), new Vector3D(0, 0, 1f), 500d); break; } if (CurrentModelVisual == null) { minZoom = maxZoom = _modelCameraPosition.DistanceTo(new Point3D()); } _CurrentCameraPosition = cameraPosition; }
public static void DebugLine(Creature creature, Point3D start, Point3D end) { const int iterations = 3; Point3D vector = Geom.GetNormal(Geom.GetHeading(start, end)) .Multiple((float)(start.DistanceTo(end) / (iterations - 1))); for (int i = 0; i < iterations; i++) { DropItem(creature, 20000001, 0, start.ToWorldPosition(), true); start.Add(vector); } Player player = creature as Player; if (player != null) { player.Visible.Update(); } }
public static void Main() { Point3D p1 = new Point3D(12, 3.5, -7); Point3D p2 = new Point3D(-15, 3.4, 17); Console.WriteLine("Points {0} and {1}:", p1.ToString(), p2.ToString()); Console.WriteLine("Distance: {0}", p1.DistanceTo(p2)); Console.WriteLine("p1.x : {0}", p1.GetX()); p2.SetX(-34.567); Console.WriteLine("p2.x now is : {0}", p2.GetX()); p2.MoveTo(0, 0, 0); Console.WriteLine("P2 is now:" + p2.ToString()); // ... }
/// <summary> /// Calculates the distance from a point to the nearest point on the sphere surface. /// </summary> /// <param name="point"> /// The point. /// </param> /// <returns> /// The distance. /// </returns> public double DistanceFrom(Point3D point) { return(point.DistanceTo(this.center) - this.radius); }
private async void ProcessArea(Creature creature, Skill skill, Targeting targeting, TargetingArea area, Projectile projectile = null) { try { bool isProjectileSkill = skill.Type == SkillType.Projectile || skill.Type == SkillType.Userslug; int skillId = creature.Attack.Args.SkillId; if (isProjectileSkill) { skillId += 20; } if (targeting.Time > 0) { await Task.Delay((int)(targeting.Time / skill.TimeRate)); } int elapsed = targeting.Time; Player player = creature as Player; do { try { if (creature.LifeStats.IsDead()) { return; } if (area.DropItem != null) { creature.Instance.AddDrop(new Item { Owner = player, ItemId = (int)area.DropItem, Count = 1, Position = Geom.ForwardPosition(creature.Position, 40), Instance = player.Instance, }); } Point3D center = projectile != null ? projectile.Position.ToPoint3D() : Geom.GetNormal(creature.Position.Heading) .Multiple(area.OffsetDistance) .Add(creature.Position); int count = 0; List <Creature> targets = creature.Attack.Args.Targets.Count > 0 ? creature.Attack.Args.Targets : VisibleService.FindTargets(creature, center, projectile != null ? projectile.AttackDistance : area.MaxRadius, area.Type); foreach (Creature target in targets) { if (target != creature && //Ignore checks for self-target !isProjectileSkill && !creature.Attack.Args.IsItemSkill) { if (center.DistanceTo(target.Position) < area.MinRadius - 40) { continue; } if (center.DistanceTo(target.Position) > area.MaxRadius) { continue; } short diff = Geom.GetAngleDiff(creature.Attack.Args.StartPosition.Heading, Geom.GetHeading(center, target.Position)); //diff from 0 to 180 //area.RangeAngel from 0 to 360 if (diff * 2 > (creature.Attack.Args.IsTargetAttack ? 90 : Math.Abs(area.RangeAngle) + 10)) { continue; } } if (skill.TotalAtk > 0) { int damage = SeUtils.CalculateDamage(creature, target, skill.TotalAtk * area.Effect.Atk); AttackResult result = new AttackResult { AttackType = AttackType.Normal, AttackUid = creature.Attack.UID, Damage = damage, Target = target, }; result.AngleDif = Geom.GetAngleDiff(creature.Attack.Args.StartPosition.Heading, result.Target.Position.Heading); SeUtils.UpdateAttackResult(creature, result); if (result.AttackType == AttackType.Block) { VisibleService.Send(target, new SpAttackShowBlock(target, skillId)); } VisibleService.Send(target, new SpAttackResult(creature, skillId, result)); AiLogic.OnAttack(creature, target); AiLogic.OnAttacked(target, creature, result.Damage); if (target is Player && ((Player)target).Duel != null && player != null && ((Player)target).Duel.Equals(player.Duel) && target.LifeStats.GetHpDiffResult(damage) < 1) { DuelService.FinishDuel(player); } else { CreatureLogic.HpChanged(target, target.LifeStats.MinusHp(result.Damage)); } } if (area.Effect.HpDiff > 0) { AttackResult result = new AttackResult { HpDiff = area.Effect.HpDiff, Target = target }; PassivityProcessor.OnHeal(player, result); if (target is Player) { PassivityProcessor.OnHealed((Player)target, result); } CreatureLogic.HpChanged(target, target.LifeStats.PlusHp(result.HpDiff), creature); } if (area.Effect.MpDiff > 0) { CreatureLogic.MpChanged(target, target.LifeStats.PlusMp(area.Effect.MpDiff), creature); } if (area.Effect.AbnormalityOnCommon != null) { for (int i = 0; i < area.Effect.AbnormalityOnCommon.Count; i++) { AbnormalityProcessor.AddAbnormality(target, area.Effect.AbnormalityOnCommon[i], creature); } } if (player != null) { DuelService.ProcessDamage(player); //MP regen on combo skill if (skill.Id / 10000 == 1 && player.GameStats.CombatMpRegen > 0) { CreatureLogic.MpChanged(player, player.LifeStats.PlusMp( player.MaxMp * player.GameStats.CombatMpRegen / 200)); } } if (++count == area.MaxCount) { break; } } } catch (Exception ex) { Logger.WriteLine(LogState.Exception, "SkillEngine: ProcessAreaExc: " + ex); } if (targeting.Interval > 0) { await Task.Delay((int)(targeting.Interval / skill.TimeRate)); elapsed += targeting.Interval; } } while (targeting.Interval > 0 && elapsed < targeting.Until); } catch (Exception ex) { Logger.WriteLine(LogState.Exception, "SkillEngine: ProcessArea: " + ex); } }
public double DistanceTo() { return(P1.DistanceTo(P2)); }
private void Open3DView(VisualizationInfo v) { try { // { // Tuple <Point3D, Vector3D, Vector3D, ViewpointProjection, double> tuple = GetViewCoordinates(v); if (tuple == null) { MessageBox.Show("Viewpoint not formatted correctly.", "Viewpoint Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } Document oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument; // get current viewpoint // Viewpoint oCurVP = oDoc.vi.CurrentViewpoint.ToViewpoint; // get copy viewpoint Viewpoint oCopyVP = new Viewpoint(); oCopyVP.AlignDirection(tuple.Item3); oCopyVP.AlignUp(tuple.Item2); oCopyVP.Projection = tuple.Item4; // **** CUSTOM VALUE FOR TEKLA **** // // otherwise = 1 // **** CUSTOM VALUE FOR TEKLA **** // const double TEKLA = 1.25; double x = tuple.Item5 / TEKLA; if (oCopyVP.Projection == ViewpointProjection.Orthographic) { oCopyVP.Position = tuple.Item1; oCopyVP.FocalDistance = 1; //top center point of view Point3D xyzTL = oCopyVP.Position.Add(tuple.Item2.Multiply(x)); oCopyVP.SetExtentsAtFocalDistance(1, xyzTL.DistanceTo(oCopyVP.Position)); } else { //double angle = tuple.Item5 * Math.PI / 180; // MessageBox.Show(tuple.Item5.ToString() + " " +(Math.Tan(angle / 2)*2).ToString()); oCopyVP.FocalDistance = tuple.Item5; //oCopyVP.SetExtentsAtFocalDistance(Math.Tan(angle / 2) * 2, Math.Tan(angle / 2) * 2 / oCopyVP.AspectRatio); oCopyVP.Position = tuple.Item1; } oDoc.CurrentViewpoint.CopyFrom(oCopyVP); if (v.Components != null && v.Components.Any()) { // ModelItemCollection selected = new ModelItemCollection(); List <ModelItem> attachedElems = new List <ModelItem>(); List <ModelItem> elems = oDoc.Models.First.RootItem.DescendantsAndSelf.ToList <ModelItem>(); foreach (var item in elems.Where(o => o.InstanceGuid != Guid.Empty)) { string ifcguid = IfcGuid.ToIfcGuid(item.InstanceGuid).ToString(); if (v.Components.Any(o => o.IfcGuid == ifcguid)) { attachedElems.Add(item); } } if (attachedElems.Any())//avoid to hide everything if no elements matches { if (MySettings.Get("selattachedelems") == "0") { List <ModelItem> elemsVisible = new List <ModelItem>(); foreach (var item in attachedElems) { elemsVisible.AddRange(item.AncestorsAndSelf); } foreach (var item in elemsVisible) { elems.Remove(item); } oDoc.Models.ResetAllHidden(); oDoc.Models.SetHidden(elems, true); } else { oDoc.CurrentSelection.Clear(); oDoc.CurrentSelection.AddRange(attachedElems); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } //setVisibility(v); }
static void CalculateRivetPose3D(Point3D cameraCenter1, Point3D pointCam1_1, Point3D pointCam1_2, Point3D cameraCenter2, Point3D pointCam2_1, Point3D pointCam2_2) { //Plane planeCam1 = new Plane(new Point3D(cameraCenter1.X, cameraCenter1.Y, cameraCenter1.Z), new Point3D(pointCam1_1.X, pointCam1_1.Y, pointCam1_1.Z), new Point3D(pointCam1_2.X, pointCam1_2.Y, pointCam1_2.Z)); Plane planeCam2 = new Plane(new Point3D(cameraCenter2.X, cameraCenter2.Y, cameraCenter2.Z), new Point3D(pointCam2_1.X, pointCam2_1.Y, pointCam2_1.Z), new Point3D(pointCam2_2.X, pointCam2_2.Y, pointCam2_2.Z)); Vector3D VectorCam1CenterToPoint1_1 = new Vector3D(pointCam1_1.X - cameraCenter1.X, pointCam1_1.Y - cameraCenter1.Y, pointCam1_1.Z - cameraCenter1.Z); Vector3D VectorCam1CenterToPoint1_2 = new Vector3D(pointCam1_2.X - cameraCenter1.X, pointCam1_2.Y - cameraCenter1.Y, pointCam1_2.Z - cameraCenter1.Z); //Ray3D rivetAxis3D = planeCam1.IntersectionWith(planeCam2); Ray3D RayCam1CenterToPoint1_1 = new Ray3D(cameraCenter1, VectorCam1CenterToPoint1_1.Normalize()); Ray3D RayCam1CenterToPoint1_2 = new Ray3D(cameraCenter1, VectorCam1CenterToPoint1_2.Normalize()); Point3D pointRivetCylinder1 = planeCam2.IntersectionWith(RayCam1CenterToPoint1_1); Point3D pointRivetCylinder2 = planeCam2.IntersectionWith(RayCam1CenterToPoint1_2); //var a = rivetAxis3D.LineTo(pointRivetCylinder1); //var b = rivetAxis3D.LineTo(pointRivetCylinder2); //Angle alpha1 = RayCam1CenterToPoint1_1.Direction.AngleTo(rivetAxis3D.Direction); //Angle alpha2 = RayCam1CenterToPoint1_2.Direction.AngleTo(rivetAxis3D.Direction); UnitVector3D intersection1To2 = new Vector3D(pointRivetCylinder2.X - pointRivetCylinder1.X, pointRivetCylinder2.Y - pointRivetCylinder1.Y, pointRivetCylinder2.Z - pointRivetCylinder1.Z).Normalize(); Angle alpha1 = RayCam1CenterToPoint1_1.Direction.AngleTo(intersection1To2); Angle alpha2 = RayCam1CenterToPoint1_2.Direction.AngleTo(intersection1To2); if (pointRivetCylinder1.DistanceTo(new Point3D(0, 0, 0)) < pointRivetCylinder2.DistanceTo(new Point3D(0, 0, 0))) { double distance1 = Math.Abs(_rivetRadius / Math.Tan(alpha1.Radians)); Vector3D distanceAlongRivetAxis1 = distance1 * intersection1To2; _rivetCenter1 = pointRivetCylinder1 + distanceAlongRivetAxis1; double distance2 = Math.Abs(_rivetRadius / Math.Tan(alpha2.Radians)); Vector3D distanceAlongRivetAxis2 = distance2 * intersection1To2; _rivetCenter2 = pointRivetCylinder2 - distanceAlongRivetAxis2; } else { double distance1 = _rivetRadius / Math.Tan(alpha1.Radians); Vector3D distanceAlongRivetAxis1 = distance1 * intersection1To2; _rivetCenter1 = pointRivetCylinder1 - distanceAlongRivetAxis1; double distance2 = _rivetRadius / Math.Tan(alpha2.Radians); Vector3D distanceAlongRivetAxis2 = distance2 * intersection1To2; _rivetCenter2 = pointRivetCylinder2 + distanceAlongRivetAxis2; } //MathNet.Spatial.Units.Angle plane1AxisAngle = planeCam1.Normal.AngleTo(rivetAxis3D.Direction); double rivetLength = Math.Sqrt(Math.Pow(_rivetCenter1.X - _rivetCenter2.X, 2) + Math.Pow(_rivetCenter1.Y - _rivetCenter2.Y, 2) + Math.Pow(_rivetCenter1.Z - _rivetCenter2.Z, 2)); //Console.WriteLine("distance between points: " + rivetLength.ToString()); //var length1 = rivetAxis3D.LineTo(pointRivetCylinder1).Length; //var length2 = rivetAxis3D.LineTo(pointRivetCylinder2).Length; //var collinear = rivetAxis3D.Direction.IsParallelTo(intersection1To2); }
public PernasPosicao LegOWASClassification(SkeletonPoint SkeletonPointAnkleRight, SkeletonPoint SkeletonPointKneeRight, SkeletonPoint SkeletonPointAnkleLeft, SkeletonPoint SkeletonPointKneeLeft, SkeletonPoint SkeletonPointHipLeft, SkeletonPoint SkeletonPointHipRight, Tuple <float, float, float, float> FloorPlane) { PernasPosicao posicaoPernas = PernasPosicao.Desconhecida; //--------------------------------------------------------------------------------------------------- //Classification of Leg //1) Duas pernas retas: As duas pernas esta no chão (classificação 2 = True) e as duas penas estão retas (classificação 1 = True para as duas pernas) . //2) Uma perna reta : As duas pernas não estão no chão (classificação 2 = False) e uma das pernas está reta ( classificação 1 = False) //3) Duas pernas flexionadas: As duas pernas esta no chão ( classificação 2 = True) e as duas penas não estão retas (classificação 1 =False para as duas pernas) . //4) Uma Perna Flexionada: As duas pernas não estão no chão (classificação 2 = False) e a perna que está no chão não está reta ( classificação 1 = False) //5) Uma perna Ajoelhada: As duas pernas esta no chão ( classificação 2 = True) e as duas pernas estão flexionada (classificação 1 =False para as duas pernas ) e pelo menos uma perna está ajoelhada (classificação 1 = False) //--------------------------------------------------------------------------------------------------- //Inicialize the value Point3D PointHipLeft = new Point3D(); Point3D PointKneeLeft = new Point3D(); Point3D PointHipRight = new Point3D(); Point3D PointKneeRight = new Point3D(); //to do: Mudar parametros da função //IsStraightByDotProduct(SkeletonPointKneeRight, SkeletonPointKneeRight, SkeletonPointHipRight, 2.8) //Perna Reta: Point3Z0GetAngleBetween(XMLSkeletonPointKneeRight, XMLSkeletonPointKneeRight) > 80 //Pé no Chão: IsFloorPlane(SkeletonPointKneeRight, FloorPlane, 0.1) PointHipLeft.X = SkeletonPointHipLeft.X; PointHipLeft.Y = SkeletonPointHipLeft.Y; PointHipLeft.Z = SkeletonPointHipLeft.Z; PointKneeLeft.X = SkeletonPointKneeLeft.X; PointKneeLeft.Y = SkeletonPointKneeLeft.Y; PointKneeLeft.Z = SkeletonPointKneeLeft.Z; PointHipRight.X = SkeletonPointHipRight.X; PointHipRight.Y = SkeletonPointHipRight.Y; PointHipRight.Z = SkeletonPointHipRight.Z; PointKneeRight.X = SkeletonPointKneeRight.X; PointKneeRight.Y = SkeletonPointKneeRight.Y; PointKneeRight.Z = SkeletonPointKneeRight.Z; if ((OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeRight, ref SkeletonPointAnkleRight) > 80 & IsFloorPlane(SkeletonPointAnkleRight, FloorPlane, 0.1)) & (OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeLeft, ref SkeletonPointAnkleLeft) > 80 & IsFloorPlane(SkeletonPointAnkleLeft, FloorPlane, 0.1))) { if ((Math.Round(PointHipLeft.DistanceTo(PointKneeLeft), 2) <= 0.35 | Math.Round(PointHipRight.DistanceTo(PointKneeRight), 2) <= 0.35)) { posicaoPernas = PernasPosicao.OneLegknee; } else { posicaoPernas = PernasPosicao.twoLegUp; } } if ((OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeRight, ref SkeletonPointAnkleRight) > 80 & IsFloorPlane(SkeletonPointAnkleRight, FloorPlane, 0.1)) | (OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeLeft, ref SkeletonPointAnkleLeft) > 80 & IsFloorPlane(SkeletonPointAnkleLeft, FloorPlane, 0.1))) { posicaoPernas = PernasPosicao.OneLegUp; } if ((OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeRight, ref SkeletonPointAnkleRight) <= 80 & IsFloorPlane(SkeletonPointAnkleRight, FloorPlane, 0.1)) & (OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeLeft, ref SkeletonPointAnkleLeft) <= 80 & IsFloorPlane(SkeletonPointAnkleLeft, FloorPlane, 0.1))) { if ((Math.Round(PointHipLeft.DistanceTo(PointKneeLeft), 2) <= 0.3 | Math.Round(PointHipRight.DistanceTo(PointKneeRight), 2) <= 0.3)) { posicaoPernas = PernasPosicao.OneLegknee; } else { posicaoPernas = PernasPosicao.twoLegFlex; } } if ((OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeRight, ref SkeletonPointAnkleRight) <= 80 & OWAS.Math.Point3Z0GetAngleBetween(ref SkeletonPointKneeLeft, ref SkeletonPointAnkleLeft) <= 80) & (IsFloorPlane(SkeletonPointAnkleRight, FloorPlane, 0.1) | IsFloorPlane(SkeletonPointAnkleLeft, FloorPlane, 0.1))) { if ((Math.Round(PointHipLeft.DistanceTo(PointKneeLeft), 2) <= 0.3 | Math.Round(PointHipRight.DistanceTo(PointKneeRight), 2) <= 0.3)) { posicaoPernas = PernasPosicao.OneLegknee; } else { posicaoPernas = PernasPosicao.OneLegFlex; } } return(posicaoPernas); }
public static Vector<double> solve( List<double[]> Vertices, List<int[]> TrianglesVertices, List<double[]> FacetNormals, Vector<double> X, Point3D oRoot, UnitVector3D vDir1, UnitVector3D vDir2, Mesh M) { //Method from article -Wang,Smith. Surface flattening based on energy model. Computer-Aided Design (2002) 823-833 //PseudoCode //Input: P - Set of nodes, in the initial position and N is the number of nodes //Output: the final positions of P with E(o) minimized // FOR i = 1 TO n // mi = p / 3 Sum(Ak), where Ak is the area // WHILE (Relative Area difference Es > Permissible accuracy or Relative edge length difference Ec > Permissible accuracy) // AND Variation of E(o) > Permissible percentage € // AND the number of iterations < Permissible number N // FOR i = 1 TO n // Compute Tensile force of Node Pi: Fi = Sum(C * (Dist(PiPj) - Dist(QiQj)))nij where(P - 2D - Q - 3D nij - Vector Pi to Pj) // Compute new position of Pi qi = qi + dtqi. + dt ^ 2 / 2 qi..where qi.= qi.+ dtqi..and qi..= Fi / mi // Compute Penalty force and aplly to Fpi // Compute new position of Pi qi = qi + dtqi. + dt ^ 2 / 2 qi..where qi.= qi.+ dtqi..and qi..= Fpi / mi // Compute new Es= Sum(TotalAreaNow - TotalAreaBefore) / TotalAreaNow // Compute new Ec= Sum(TotalLenghtNow - TotalLenghtBefore) / TotalLenghtNow // Compute new E(o)Sum(E(pi)) where E(pi) = 0.5 * Sum(C * (Dist(PiPj) - Dist(QiQj))) ^ 2 double[] Mass = new double [Vertices.Count]; int[] MassCounter = new int[Vertices.Count]; double Permissible = 0.00000001; Vector<double> Fi = Vector<double>.Build.Dense(2); List<Vector<double>> dqi = new List<Vector<double>>(); List<Vector<double>> qi = new List<Vector<double>>(); double LastEc = 0, Ec = 0; double LastEs = 0, Es = 0; double LastEo = 0, Eo = 0; double C = 0.5; double ro = 1; double t = 0.01; int N = 100; int Iteration = 0; double Total = 0; double LastTotal = 0; foreach (int[] tri in TrianglesVertices) { double A = getArea(Vertices[tri[0]], Vertices[tri[1]], Vertices[tri[2]]); double P = getPerimeter(Vertices[tri[0]], Vertices[tri[1]], Vertices[tri[2]]); Mass[tri[0]] += ((double)1 / (double)3) * A * ro; Mass[tri[1]] += ((double)1 / (double)3) * A * ro; Mass[tri[2]] += ((double)1 / (double)3) * A * ro; MassCounter[tri[0]] += 1; MassCounter[tri[1]] += 1; MassCounter[tri[2]] += 1; LastEc += A; LastEs += P; } for (int i = 0; i < Vertices.Count; i++) { Mass[i] = Mass[i] / MassCounter[i]; qi.Add(Vector<double>.Build.DenseOfArray(new double[] { X[i * 2], X[i * 2 + 1], 0 })); dqi.Add(Vector<double>.Build.DenseOfArray(new double[] { 0, 0, 0 })); } do { Iteration += 1; LastEo = Eo; Eo = 0; Total = 0; for (int i = 0; i < Vertices.Count; i++) { Point3D Pi = new Point3D(qi[i][0], qi[i][1], qi[i][2]); Point3D Qi = new Point3D(Vertices[i][0], Vertices[i][1], Vertices[i][2]); Fi = Vector<double>.Build.Dense(3); for (int j = i+1; j < Vertices.Count; j++) { if (i == j) continue; Point3D Pj = new Point3D(qi[j][0], qi[j][1], qi[j][2]); Point3D Qj = new Point3D(Vertices[j][0], Vertices[j][1], Vertices[j][2]); UnitVector3D nij = new UnitVector3D((Pi.ToVector()- Pj.ToVector()).ToArray()); Fi += C * ((Pi.DistanceTo(Pj) - Qi.DistanceTo(Qj)) * nij).ToVector(); Eo += Math.Pow(C * ((Pi.DistanceTo(Pj) - Qi.DistanceTo(Qj))), 2); } Vector<double> ddqi = Fi / Mass[i]; Console.WriteLine(Fi); dqi[i] += t * ddqi; qi[i] += dqi[i] * t + 0.5 * Math.Pow(t, 2) * ddqi; Total += Math.Abs(qi[i][0] - X[i * 2]); Total += Math.Abs(qi[i][1] - X[i * 2] + 1); } Console.WriteLine(Total- LastTotal); LastTotal = Total; LastEc = Ec; Ec = 0; LastEs = Es; Es = 0; foreach (int[] tri in TrianglesVertices) { double A = getArea(Vertices[tri[0]], Vertices[tri[1]], Vertices[tri[2]]); double P = getPerimeter(Vertices[tri[0]], Vertices[tri[1]], Vertices[tri[2]]); Ec += A; Es += P; } if (((Ec - LastEc) / Ec < Permissible || (Es - LastEs) / Es < Permissible) && (Eo - LastEo) / Eo < Permissible && Iteration > N) break; } while (true); Vector<double> XResult = Vector<double>.Build.DenseOfArray(X.ToArray()); for (int i = 0; i < Vertices.Count; i++) { //Console.WriteLine(qi[i][0] - X[i * 2]); Total += Math.Abs(qi[i][0] - X[i * 2]); XResult[i * 2] = qi[i][0]; //Console.WriteLine(qi[i][1] - X[i * 2+1]); Total += Math.Abs(qi[i][1] - X[i * 2]+1); XResult[i * 2+1] = qi[i][1]; } Console.WriteLine(Total); return XResult; }
//pernas public int LegOWASClassification(SkeletonPoint SkeletonPointAnkleRight, SkeletonPoint SkeletonPointKneeRight, SkeletonPoint SkeletonPointAnkleLeft, SkeletonPoint SkeletonPointKneeLeft, SkeletonPoint SkeletonPointHipLeft, SkeletonPoint SkeletonPointHipRight, Tuple <float, float, float, float> FloorPlane) { int functionReturnValue = 0; //--------------------------------------------------------------------------------------------------- //Classification of Leg //1) Duas pernas retas: As duas pernas esta no chão (classificação 2 = True) e as duas penas estão retas (classificação 1 = True para as duas pernas) . //2) Uma perna reta : As duas pernas não estão no chão (classificação 2 = False) e uma das pernas está reta ( classificação 1 = False) //3) Duas pernas flexionadas: As duas pernas esta no chão ( classificação 2 = True) e as duas penas não estão retas (classificação 1 =False para as duas pernas) . //4) Uma Perna Flexionada: As duas pernas não estão no chão (classificação 2 = False) e a perna que está no chão não está reta ( classificação 1 = False) //5) Uma perna Ajoelhada: As duas pernas esta no chão ( classificação 2 = True) e as duas pernas estão flexionada (classificação 1 =False para as duas pernas ) e pelo menos uma perna está ajoelhada (classificação 1 = False) //--------------------------------------------------------------------------------------------------- //Inicialize the value functionReturnValue = 0; Point3D PointHipLeft = new Point3D(); Point3D PointKneeLeft = new Point3D(); Point3D PointHipRight = new Point3D(); Point3D PointKneeRight = new Point3D(); //to do: Mudar parametros da função //IsStraightByDotProduct(SkeletonPointKneeRight, SkeletonPointKneeRight, SkeletonPointHipRight, 2.8) //Perna Reta: Point3Z0GetAngleBetween(XMLSkeletonPointKneeRight, XMLSkeletonPointKneeRight) > 80 //Pé no Chão: IsFloorPlane(SkeletonPointKneeRight, FloorPlane, 0.1) PointHipLeft.X = SkeletonPointHipLeft.X; PointHipLeft.Y = SkeletonPointHipLeft.Y; PointHipLeft.Z = SkeletonPointHipLeft.Z; PointKneeLeft.X = SkeletonPointKneeLeft.X; PointKneeLeft.Y = SkeletonPointKneeLeft.Y; PointKneeLeft.Z = SkeletonPointKneeLeft.Z; PointHipRight.X = SkeletonPointHipRight.X; PointHipRight.Y = SkeletonPointHipRight.Y; PointHipRight.Z = SkeletonPointHipRight.Z; PointKneeRight.X = SkeletonPointKneeRight.X; PointKneeRight.Y = SkeletonPointKneeRight.Y; PointKneeRight.Z = SkeletonPointKneeRight.Z; if ((Point3Z0GetAngleBetween(SkeletonPointKneeRight, SkeletonPointAnkleRight) > 80 & IsFloorPlane(SkeletonPointAnkleRight, FloorPlane, 0.1)) & (Point3Z0GetAngleBetween(SkeletonPointKneeLeft, SkeletonPointAnkleLeft) > 80 & IsFloorPlane(SkeletonPointAnkleLeft, FloorPlane, 0.1))) { if ((Math.Round(PointHipLeft.DistanceTo(PointKneeLeft), 2) <= 0.35 | Math.Round(PointHipRight.DistanceTo(PointKneeRight), 2) <= 0.35)) { return(5); } else { return(1); } } if ((Point3Z0GetAngleBetween(SkeletonPointKneeRight, SkeletonPointAnkleRight) > 80 & IsFloorPlane(SkeletonPointAnkleRight, FloorPlane, 0.1)) | (Point3Z0GetAngleBetween(SkeletonPointKneeLeft, SkeletonPointAnkleLeft) > 80 & IsFloorPlane(SkeletonPointAnkleLeft, FloorPlane, 0.1))) { return(2); } if ((Point3Z0GetAngleBetween(SkeletonPointKneeRight, SkeletonPointAnkleRight) <= 80 & IsFloorPlane(SkeletonPointAnkleRight, FloorPlane, 0.1)) & (Point3Z0GetAngleBetween(SkeletonPointKneeLeft, SkeletonPointAnkleLeft) <= 80 & IsFloorPlane(SkeletonPointAnkleLeft, FloorPlane, 0.1))) { if ((Math.Round(PointHipLeft.DistanceTo(PointKneeLeft), 2) <= 0.3 | Math.Round(PointHipRight.DistanceTo(PointKneeRight), 2) <= 0.3)) { return(5); } else { return(3); } } if ((Point3Z0GetAngleBetween(SkeletonPointKneeRight, SkeletonPointAnkleRight) <= 80 & Point3Z0GetAngleBetween(SkeletonPointKneeLeft, SkeletonPointAnkleLeft) <= 80) & (IsFloorPlane(SkeletonPointAnkleRight, FloorPlane, 0.1) | IsFloorPlane(SkeletonPointAnkleLeft, FloorPlane, 0.1))) { if ((Math.Round(PointHipLeft.DistanceTo(PointKneeLeft), 2) <= 0.3 | Math.Round(PointHipRight.DistanceTo(PointKneeRight), 2) <= 0.3)) { return(5); } else { return(4); } } return(0); return(functionReturnValue); }
public static void Open(Document doc, VisualizationInfo v) { try { NavisUtils.GetGunits(doc); Viewpoint viewpoint = new Viewpoint(); //orthogonal if (v.OrthogonalCamera != null) { if (v.OrthogonalCamera.CameraViewPoint == null || v.OrthogonalCamera.CameraUpVector == null || v.OrthogonalCamera.CameraDirection == null) { return; } var zoom = v.OrthogonalCamera.ViewToWorldScale.ToInternal(); var cameraDirection = NavisUtils.GetNavisVector(v.OrthogonalCamera.CameraDirection); var cameraUpVector = NavisUtils.GetNavisVector(v.OrthogonalCamera.CameraUpVector); var cameraViewPoint = NavisUtils.GetNavisXYZ(v.OrthogonalCamera.CameraViewPoint); viewpoint.Position = cameraViewPoint; viewpoint.AlignUp(cameraUpVector); viewpoint.AlignDirection(cameraDirection); viewpoint.Projection = ViewpointProjection.Orthographic; viewpoint.FocalDistance = 1; //TODO //for better zooming from revit should use > zoom * 1.25 //for better zooming from tekla should use > zoom / 1.25 //still not sure why Point3D xyzTL = cameraViewPoint.Add(cameraUpVector.Multiply(zoom)); var dist = xyzTL.DistanceTo(cameraViewPoint); viewpoint.SetExtentsAtFocalDistance(1, dist); } //perspective else if (v.PerspectiveCamera != null) { if (v.PerspectiveCamera.CameraViewPoint == null || v.PerspectiveCamera.CameraUpVector == null || v.PerspectiveCamera.CameraDirection == null) { return; } var zoom = v.PerspectiveCamera.FieldOfView; var cameraDirection = NavisUtils.GetNavisVector(v.PerspectiveCamera.CameraDirection); var cameraUpVector = NavisUtils.GetNavisVector(v.PerspectiveCamera.CameraUpVector); var cameraViewPoint = NavisUtils.GetNavisXYZ(v.PerspectiveCamera.CameraViewPoint); viewpoint.Position = cameraViewPoint; viewpoint.AlignUp(cameraUpVector); viewpoint.AlignDirection(cameraDirection); viewpoint.Projection = ViewpointProjection.Perspective; viewpoint.FocalDistance = zoom; } doc.CurrentViewpoint.CopyFrom(viewpoint); //show/hide elements //todo: needs improvement //todo: add settings if (v.Components != null) { List <ModelItem> attachedElems = new List <ModelItem>(); List <ModelItem> elems = doc.Models.First.RootItem.DescendantsAndSelf.ToList <ModelItem>(); foreach (var item in elems.Where(o => o.InstanceGuid != Guid.Empty)) { string ifcguid = IfcGuid.ToIfcGuid(item.InstanceGuid).ToString(); //if (v.Components.Any(o => o.IfcGuid == ifcguid)) attachedElems.Add(item); } if (attachedElems.Any()) //avoid to hide everything if no elements matches { if (UserSettings.Get("selattachedelems") == "0") { List <ModelItem> elemsVisible = new List <ModelItem>(); foreach (var item in attachedElems) { elemsVisible.AddRange(item.AncestorsAndSelf); } foreach (var item in elemsVisible) { elems.Remove(item); } doc.Models.ResetAllHidden(); doc.Models.SetHidden(elems, true); } else { doc.CurrentSelection.Clear(); doc.CurrentSelection.AddRange(attachedElems); } } } } catch (System.Exception ex1) { MessageBox.Show("exception: " + ex1, "Error opening view"); } }
public Circle3D(Point3D p1, Point3D p2, UnitVector3D axis) { this.CenterPoint = Point3D.MidPoint(p1, p2); this.Axis = axis; this.Radius = p1.DistanceTo(CenterPoint); }