//------------------------------------------------------------------------------------------ //Получить траекторию public Curve2D GetTrajectory(Point pointOne, Point pointTwo) { int interferogramsCount = this.interferograms.Length; int pointOneCoordinateX = pointOne.X; int pointOneCoordinateY = pointOne.Y; int pointTwoCoordinateX = pointTwo.X; int pointTwoCoordinateY = pointTwo.Y; double[] intensitiesAtPointOne = new double[interferogramsCount]; double[] intensitiesAtPointTwo = new double[interferogramsCount]; for (int index = 0; index < interferogramsCount; index++) { RealMatrix interferogram = interferograms[index]; double intensityAtPointOne = interferogram[pointOneCoordinateY, pointOneCoordinateX]; double intensityAtPointTwo = interferogram[pointTwoCoordinateY, pointTwoCoordinateX]; intensitiesAtPointOne[index] = intensityAtPointOne; intensitiesAtPointTwo[index] = intensityAtPointTwo; } Curve2D trajectory = new Curve2D(intensitiesAtPointOne, intensitiesAtPointTwo); return(trajectory); }
//--------------------------------------------------------------------------------------------- //Трансформация траектоории (центрирование, поворот, растяжение) private Curve2D TransformateTrajectory( Curve2D trajectory, EllipseDescriptor approximateEllipse ) { //Центрирование Curve2D transformedTrajectory = this.CentreTrajectory(trajectory, approximateEllipse); //Поворот параллельно координатной оси double rotationAngleToAxis = approximateEllipse.GetAngleBetweenOxAndPrincipalAxis(); transformedTrajectory = this.RotateTrajectory(transformedTrajectory, rotationAngleToAxis); //Растяжение EllipseOrientaion primaryOrientation = approximateEllipse.GetOrientaion(); TrajectoryOrientation trajectoryOrientation = this.DetectTrajectoryOrientation(primaryOrientation, rotationAngleToAxis); double koefficientOfStretch = 1 / approximateEllipse.GetCompressionRatio(); transformedTrajectory = this.StretchingTrajectory (transformedTrajectory, trajectoryOrientation, koefficientOfStretch); //Поворот траектории до пересечения первой точки с осью OX Point2D firstPointTrajectory = transformedTrajectory[0]; double rotationAngle = Mathem.Arctg(firstPointTrajectory.Y, firstPointTrajectory.X); transformedTrajectory = this.RotateTrajectory(transformedTrajectory, rotationAngle); return(transformedTrajectory); }
// TODO: somehow get rid of this public static void Reset() { s_ExtrusionMode = false; s_Curve2D = null; s_Points.Clear(); PointDrawing.Reset(); }
public void Init() { Func <double, double, double> rightPart = (r, t) => 0; Grid1D grid = Grid1D.Build(0, 1, 100); double[] ut0 = new double[grid.N]; for (int i = 0; i < grid.N; i++) { ut0[i] = 0; } TimeLimitCondition timeLimitCondition = new TimeLimitCondition(2 * Math.PI); var boundaryConditions = new[] { new BoundaryCondition(t => 0, BoundaryConditionLocation.Left, BoundaryConditionType.Dirichlet), new BoundaryCondition(t => Math.Cos(t), BoundaryConditionLocation.Right, BoundaryConditionType.Dirichlet) }; var scheme = new CrankNicolsonCylindricScheme1D(boundaryConditions, (r, t) => - (Math.Cos(t) / r) - r * Math.Sin(t), 1); var solution = scheme.Solve(timeLimitCondition, grid, ut0, 1E-3); Func <double, double, double> uExact = (r, t) => r * t; int n = 0; foreach (var layer in solution.Layers) { double[] g = new double[grid.N]; grid.CopyTo(g, 0); Shape2D shape = new Curve2D(g, layer); shape.Color = Color.Black; shape.Visible = true; shapes.Add(shape); } }
//------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------- public double[] Compute( Point pointOne, Point pointTwo, int interferogramIndexOne, int interferogramIndexTwo ) { TrajectoryCreator trajectoryCreator = new TrajectoryCreator(this.interferograms); Curve2D trajectory = trajectoryCreator.GetTrajectory(pointOne, pointTwo); Point2D[] points = trajectory.GetPoints(); this.TrajectoryPoints = points; EllipseApproximator ellipseApproximator = new EllipseApproximator(); EllipseDescriptor ellipseDescriptor = ellipseApproximator.Approximate(points); Point2D ellipseCentre = ellipseDescriptor.GetCentre(); points = PlaneManager.DisplacePoints(points, -ellipseCentre.X, -ellipseCentre.Y); double x0 = points[0].X; double y0 = points[0].Y; double x1 = points[interferogramIndexOne].X; double y1 = points[interferogramIndexOne].Y; double x2 = points[interferogramIndexTwo].X; double y2 = points[interferogramIndexTwo].Y; double[] phaseShifts = this.GetPhaseShifts(x0, y0, x1, y1, x2, y2); return(phaseShifts); }
// public void ShootGun(Position2D muzzle) public void ShootGun(Curve2D curve) { GD.Print("Fired"); // var dir = new Vector2(1, 0).Rotated(muzzle.GlobalRotation); // EmitSignal("Shoot", Bullet, muzzle.GlobalPosition, dir); EmitSignal("Shoot", curve, Bullet); }
static Curve2D GetShape() { if (s_Points.Count < 2) { s_Curve2D = null; return(null); } if (s_Curve2D == null) { s_Curve2D = new Curve2D(); s_Curve2D.closed = true; } var pointCount = s_ExtrusionMode ? s_Points.Count - 1 : s_Points.Count; if ((s_Points[pointCount - 1] - s_Points[0]).sqrMagnitude < PointDrawing.kDistanceEpsilon) { pointCount--; } if (s_Curve2D.controlPoints.Length != pointCount) { s_Curve2D.controlPoints = new CurveControlPoint2D[pointCount]; } for (int i = 0; i < pointCount; i++) { s_Curve2D.controlPoints[i].position = new Vector2(s_Points[i].x, s_Points[i].z); } return(s_Curve2D); }
public Bitmap eve_historyimg(int i) { List <EVE_Central.Model.Hiosty> modelist = eve_historylist(i); int x = modelist.Count; int g = 0; if (x > 30) { g = x - 30 - 1; } float[] fltsValues = new float[60]; int d = 0; string[] strsKeys = new string[] { "-30", "", "", "", "", "-25", "", "", "", "", "-20", "", "", "", "", "-15", "", "", "", "", "-10", "", "", "", "", "-5", "", "", "", "0" }; for (int k = x - 1; k >= 0 + g; k--) { fltsValues[d] = float.Parse(modelist[k].highest.ToString()); fltsValues[d + 29] = float.Parse(modelist[k].lowest.ToString()); d++; } EVE_Central.BLL.typrID bll = new typrID(); EVE_Central.Model.typrID mode = new Model.typrID(); mode = bll.GetModelfromtypeID(i); EVE_Central.Basis.Curve2D cuv2D = new Curve2D(); cuv2D.set(mode.name_en + "曲线图", " 时间", "价格", strsKeys, fltsValues); cuv2D.Fit(); return(cuv2D.CreateImage()); }
//------------------------------------------------------------------------------------------- //Вычислить фазовые сдвиги public double[] Compute( Point pointOne, Point pointTwo ) { TrajectoryCreator trajectoryCreator = new TrajectoryCreator(this.interferograms); Curve2D trajectory = trajectoryCreator.GetTrajectory(pointOne, pointTwo); IntensitiesForPointOne = trajectory.GetArrayX(); EllipseApproximator approximator = new EllipseApproximator(); Point2D[] trajectoryPoints = trajectory.GetPoints(); this.TrajectoryPoints = trajectoryPoints; QuadricCurveDescriptor approximatingQuadricCurve = approximator.Approximate(trajectoryPoints); EllipseDescriptor approximatingEllipse = approximatingQuadricCurve as EllipseDescriptor; double startX = 0; double finishX = 255; double step = 1; this.EllipsePoints = approximatingEllipse.GetPoints(startX, finishX, step); Curve2D transformedTrajectory = this.TransformateTrajectory(trajectory, approximatingEllipse); double[] phaseShifts = this.CalculatePhaseShifts(transformedTrajectory); double[] correctedPhaseShifts = this.CorrectPhaseShifts(phaseShifts); return(correctedPhaseShifts); }
public void UpdateStraightPath(Vector2 fromPos, Vector2 toPos) { _pathEndReached = false; _currentT = 0f; var result = GetViewport().GetWorld2d().DirectSpaceState.Raycast(fromPos, toPos, null, 1 << 0); Curve = GameZone.GetPathCurve(fromPos, result?.Position ?? toPos, 0f); }
protected override void OnResetInternal() { path = new Path(Path.Default); shape = new Curve2D(DefaultShape); curveSegments = 8; surfaceAssets = null; surfaceDescriptions = null; base.OnResetInternal(); }
public static ShapeExtrusionState Do(Rect dragArea, out Curve2D shape, out float height, out ChiselModel modelBeneathCursor, out Matrix4x4 transformation, Axis axis) { try { if (!s_ExtrusionMode) { // TODO: handle snapping against own points // TODO: handle ability to 'commit' PointDrawing.PointDrawHandle(dragArea, ref s_Points, out s_Transformation, out s_ModelBeneathCursor, releaseOnMouseUp: true, UnitySceneExtensions.SceneHandles.OutlinedDotHandleCap); if (s_Points.Count <= 1) { return(ShapeExtrusionState.HoverMode); } if (s_Points.Count <= 3) { return(ShapeExtrusionState.ShapeMode); } if ((s_Points[s_Points.Count - 2] - s_Points[0]).sqrMagnitude < PointDrawing.kDistanceEpsilon) { s_ExtrusionMode = true; s_Points[s_Points.Count - 1] = s_Points[0]; return(ShapeExtrusionState.Create); } return(ShapeExtrusionState.ShapeMode); } else { var tempPoint = s_Points[s_Points.Count - 1]; var oldMatrix = UnityEditor.Handles.matrix; UnityEditor.Handles.matrix = UnityEditor.Handles.matrix * s_Transformation; var extrusionState = ExtrusionHandle.DoHandle(dragArea, ref tempPoint, axis); UnityEditor.Handles.matrix = oldMatrix; s_Points[s_Points.Count - 1] = tempPoint; switch (extrusionState) { case ExtrusionState.Cancel: { s_ExtrusionMode = false; return(ShapeExtrusionState.Cancel); } case ExtrusionState.Commit: { s_ExtrusionMode = false; return(ShapeExtrusionState.Commit); } case ExtrusionState.Modified: { return(ShapeExtrusionState.Modified); } } return(ShapeExtrusionState.ExtrusionMode); } } finally { modelBeneathCursor = s_ModelBeneathCursor; transformation = s_Transformation; shape = GetShape(); height = GetHeight(axis); } }
public static Curve2D GetStraightCurve(Vector2 fromPos, Vector2 toPos) { var curve = new Curve2D(); var raycast = Instance.GetViewport().GetWorld2d().DirectSpaceState.Raycast(fromPos, toPos, null, 1); var endPos = raycast?.Position ?? toPos; curve.AddPoint(fromPos); curve.AddPoint(endPos); return(curve); }
//------------------------------------------------------------------------------------------- //Поворот траектории private Curve2D RotateTrajectory( Curve2D trajectory, double rotationAngle //Угол поворота ) { Curve2D transformedTrajectory = trajectory.GetRotatedCurve(rotationAngle); return(transformedTrajectory); }
//------------------------------------------------------------------------------------------ //Получить траекторию public static Curve2D GetTrajectory( Point pointOne, Point pointTwo, params RealMatrix[] interferograms ) { TrajectoryCreator trajectoryCreator = new TrajectoryCreator(interferograms); Curve2D trajectory = trajectoryCreator.GetTrajectory(pointOne, pointTwo); return(trajectory); }
public void UpdatePathToPlayer() { _pathEndReached = false; var player = GetTree().GetFirstNodeInGroup <Player>(Player.GROUP); if (player != null) { Curve = GameZone.GetPathCurve(_owner.GlobalPosition, player.GlobalPosition, 10f); _currentT = 0f; } }
//--------------------------------------------------------------------------------------------- //Центрирование траектории private Curve2D CentreTrajectory( Curve2D trajectory, //Траектория EllipseDescriptor approximatingEllipse //Аппроксимирующий эллипс ) { Point2D centreEllipse = approximatingEllipse.GetCentre(); Curve2D transformedTrajectory = trajectory.GetDisplacementCurve(-centreEllipse.X, -centreEllipse.Y); return(transformedTrajectory); }
public void Reset() { curveSegments = kDefaultCurveSegments; path = new ChiselPath(ChiselPath.Default); shape = new Curve2D(kDefaultShape); if (surfaceDefinition != null) { surfaceDefinition.Reset(); } }
public void Reset() { // TODO: create constants shape = kDefaultShape; startAngle = 0.0f; totalAngle = 360.0f; curveSegments = kDefaultCurveSegments; revolveSegments = kDefaultRevolveSegments; surfaceAssets = null; surfaceDescriptions = null; }
public static void GetPathVertices(Curve2D shape, int shapeCurveSegments, List <Vector2> shapeVertices, List <int> shapeSegmentIndices) { var points = shape.controlPoints; var length = points.Length; for (int i = 0; i < points.Length; i++) { var index1 = i; var index2 = (i + 1) % points.Length; var p1 = points[index1]; var p2 = points[index2]; var v1 = p1.position; var v2 = p2.position; if (shapeCurveSegments == 0 || (points[index1].constraint2 == ControlPointConstraint.Straight && points[index2].constraint1 == ControlPointConstraint.Straight)) { shapeVertices.Add(v1); shapeSegmentIndices.Add(i); continue; } Vector2 v0, v3; if (p1.constraint2 != ControlPointConstraint.Straight) { v0 = v1 - p1.tangent2; } else { v0 = v1; } if (p2.constraint1 != ControlPointConstraint.Straight) { v3 = v2 - p2.tangent1; } else { v3 = v2; } int first_index = shapeVertices.Count; shapeSegmentIndices.Add(i); shapeVertices.Add(v1); for (int n = 1; n < shapeCurveSegments; n++) { shapeSegmentIndices.Add(i); shapeVertices.Add(PointOnBezier(v1, v0, v3, v2, n / (float)shapeCurveSegments)); } } }
//------------------------------------------------------------------------------------------- //Вычисление фазовых сдвигов по траектории private double[] CalculatePhaseShifts(Curve2D trajectory) { int shiftsCount = trajectory.PointsCount; double[] phaseShifts = new double[shiftsCount]; for (int index = 0; index < shiftsCount; index++) { Point2D point = trajectory[index]; double phaseShift = Mathem.Arctg(point.Y, point.X); phaseShifts[index] = phaseShift; } return(phaseShifts); }
public void Reset() { // TODO: create constants shape = kDefaultShape; startAngle = 0.0f; totalAngle = 360.0f; curveSegments = kDefaultCurveSegments; revolveSegments = kDefaultRevolveSegments; if (surfaceDefinition != null) { surfaceDefinition.Reset(); } }
public static ChiselBlobAssetReference <ChiselCurve2DBlob> Convert(Curve2D curve, Allocator allocator) { using (var builder = new ChiselBlobBuilder(Allocator.Temp)) { ref var root = ref builder.ConstructRoot <ChiselCurve2DBlob>(); root.closed = curve.closed; var srcControlPoints = curve.controlPoints; var dstControlPoints = builder.Allocate(ref root.controlPoints, srcControlPoints.Length); // TODO: just use fixed-array + memcpy for (int i = 0; i < srcControlPoints.Length; i++) { dstControlPoints[i] = Convert(srcControlPoints[i]); } return(builder.CreateBlobAssetReference <ChiselCurve2DBlob>(allocator)); }
public Vector3 GetHighestPoint() { var d = (myC.y - myA.y) / myCurve2D.myLength; var e = myA.y - myC.y; var curveCompl = new Curve2D(myCurve2D.myA, myCurve2D.myB + d, myCurve2D.myC + e, myCurve2D.myLength); Vector3 E = new Vector3(); E.y = curveCompl.myE.y; E.x = myA.x + (myC.x - myA.x) * (curveCompl.myE.x / curveCompl.myLength); E.z = myA.z + (myC.z - myA.z) * (curveCompl.myE.x / curveCompl.myLength); return(E); }
private void _on_Shooter_Shoot(Curve2D curve, PackedScene bullet) { var b = (TestBullet2)bullet.Instance(); _path.Curve = curve; PathFollow2D follow = new PathFollow2D(); follow.SetOffset(10); follow.AddChild(b); b.Position = new Vector2(); _path.AddChild(follow); _path.Visible = true; follow.Show(); GD.Print("shoot"); }
public void Validate() { if (surfaceDefinition == null) { surfaceDefinition = new ChiselSurfaceDefinition(); } if (shape == null) { shape = new Curve2D(kDefaultShape); } int sides = shape.controlPoints.Length; surfaceDefinition.EnsureSize(2 + sides); }
private void RefreshCurveNormal() { Ray r1 = new Ray(myA, myC - myA); var v1 = ClosestPointInLine(r1, myB); Vector2 A2d, B2d, C2d; A2d.x = 0f; A2d.y = 0f; B2d.x = Vector3.Distance(myA, v1); B2d.y = Vector3.Distance(myB, v1); C2d.x = Vector3.Distance(myA, myC); C2d.y = 0f; myCurve2D = new Curve2D(A2d, B2d, C2d); myH = (myB - v1) / Vector3.Distance(v1, myB) * myCurve2D.myE.y; }
private void RefreshCurveClose() { var fac01 = (myA.y <= myB.y) ? 1f : -1f; var fac02 = (myA.y <= myC.y) ? 1f : -1f; Vector2 A2d, B2d, C2d; A2d.x = 0f; A2d.y = 0f; B2d.x = 1f; B2d.y = Vector3.Distance((myA + myC) / 2f, myB) * fac01; C2d.x = 2f; C2d.y = Vector3.Distance(myA, myC) * fac02; myCurve2D = new Curve2D(A2d, B2d, C2d); myH = Vector3.up; }
public override void FillData() { List <SolutionItemColoredModel> solutionItems = View.Model.SolutionItems; View.FillListView(solutionItems); View.Model.Curves.Clear(); string exactSolverType = typeof(PulsationLaminarExactSolver).Name; using (CalculationDbContext db = new CalculationDbContext()) { var exactSolution = solutionItems.FirstOrDefault(s => s.Item.SolverType == exactSolverType); if (exactSolution == null) { return; } int exactSolutionId = exactSolution.Item.Id; var exactBundle = db.GetBundle(exactSolutionId); var exactLayers = exactBundle.GetAllArrays(); List <Curve2D> curves = new List <Curve2D>(); foreach (var solutionItemColored in solutionItems) { var solutionItem = solutionItemColored.Item; var bundle = db.GetBundle(exactSolutionId); if (solutionItem.SolverType != exactSolverType) { var layers = bundle.GetAllArrays(); Curve2D curve = new Curve2D(solutionItemColored.Color); double t = 0; for (int i = 0; i < exactSolution.Item.Count; i++) { double max = exactLayers[i].Subtract(layers[i]).NormInf(); curve.Add(t, max); t += solutionItem.dt; } curves.Add(curve); View.Model.Curves.Add(solutionItem.Name, curve); } } } }
protected virtual void Curv2(IObjReaderState state, ObjToken token, string[] values) { if (values.Length < 3) { throw new InvalidDataException(string.Format("The <{0}> statement must specify at least 2 values. Line: {1}.", token, state.LineNumber)); } var curve = new Curve2D(); for (int i = 1; i < values.Length; i++) { int vp = int.Parse(values[i], CultureInfo.InvariantCulture); if (vp == 0) { throw new InvalidDataException(string.Format("The <{0}> statement contains an invalid parameter space vertex index. Line: {1}.", token, state.LineNumber)); } if (vp < 0) { vp = state.Obj.SpaceVertices.Count + vp + 1; } if (vp <= 0 || vp > state.Obj.SpaceVertices.Count) { throw new IndexOutOfRangeException(); } curve.SpaceVertices.Add(vp); } state.ApplyAttributesToElement(curve); state.ApplyAttributesToFreeFormElement(curve); state.FreeFormElement = curve; state.Obj.Curves2D.Add(curve); foreach (var group in state.GetCurrentGroups()) { group.Curves2D.Add(curve); } }