public void MoveOnWestHeadingFromZeroXAxisShouldReturnNegativeXAxis() { var heading = Heading.West; var start = new Point(0, 2); var result = PositionCalculator.Move(heading, start); Assert.AreEqual(new Point(-1, 2), result); }
public void MoveOnNorthHeadingFromNegativeYAxisShouldReturnZeroYAxis() { var heading = Heading.North; var start = new Point(2, -1); var result = PositionCalculator.Move(heading, start); Assert.AreEqual(new Point(2, 0), result); }
public void DivisionWithoutRest() { int[] segments = PositionCalculator.Divide(2100, 2, 5); Assert.AreEqual(4, segments.Length); Assert.AreEqual(150, segments[0]); Assert.AreEqual(900, segments[1]); Assert.AreEqual(900, segments[2]); Assert.AreEqual(150, segments[3]); }
private float3 GetCellPosition(int x, int y, int z) { Vector3 position; position.x = PositionCalculator.GetPositionX(x, z); position.y = PositionCalculator.GetPositionY(y); position.z = PositionCalculator.GetPositionZ(z); return(new float3(position.x, position.y, position.z)); }
void InitPositionCalculator() { GameObject[] lefties = GameObject.FindGameObjectsWithTag("Lefty"); Transform[] leftyTrans = new Transform[lefties.Length]; for (int i = 0; i < lefties.Length; i++) { leftyTrans[i] = lefties[i].transform; } positionCalculator = new PositionCalculator(leftyTrans, gameObject.transform); }
public ActionResult position(long id) { var calc = new PositionCalculator(); calc.CalculateAndSaveSubjectPosition(id); var sb = new StringBuilder(); return(Content("done")); }
/// <summary> /// Set rules, moves, selection handler, position calculator, hexagon logic and unity interface board. /// </summary> private void SetLevel() { var rules = HexagonRule.Rules(colorNo); var moves = HexagonMove.Moves(); touchMoves = new SelectionHandler(xTreeSize, yTreeSize); positionCalculator = new PositionCalculator(xTreeSize, yTreeSize); hexagonLogic = new HexagonLogic(xTreeSize, yTreeSize, colorNo, rules, moves); SetBoard(); selectedCoords = null; }
public void LengthOfAllSegmentsMustBeDivisibleByTen() { int[] segments = PositionCalculator.Divide(5000, 0, 3); Assert.AreEqual(8, segments.Length); Assert.AreEqual(100, segments[0]); Assert.AreEqual(800, segments[1]); Assert.AreEqual(790, segments[2]); Assert.AreEqual(790, segments[3]); Assert.AreEqual(790, segments[4]); Assert.AreEqual(790, segments[5]); Assert.AreEqual(790, segments[6]); Assert.AreEqual(150, segments[7]); }
public void Test() { int[] segments = PositionCalculator.Divide(5000, 0, 1); Assert.AreEqual(8, segments.Length); Assert.AreEqual(100, segments[0]); Assert.AreEqual(800, segments[1]); Assert.AreEqual(800, segments[2]); Assert.AreEqual(800, segments[3]); Assert.AreEqual(800, segments[4]); Assert.AreEqual(800, segments[5]); Assert.AreEqual(800, segments[6]); Assert.AreEqual(100, segments[7]); }
public void Should_Get_Correct_DepthPosition() { string[] instructions = new string[] { "forward 5", "down 5", "forward 8", "up 3", "down 8", "forward 2", }; var result = PositionCalculator.GetFinalDepthByFinalPosition(instructions); Assert.Equal(150, result); }
public Position GetPlanePosition() { return(FsxOperation(() => { double latitudeHigh = GetFsxData(FsxDataOffset.LatitudeHigh); double latitudeLow = GetFsxData(FsxDataOffset.LatitudeLow); double longitudeHigh = GetFsxData(FsxDataOffset.LongitudeHigh); double longitudeLow = GetFsxData(FsxDataOffset.LongitudeLow); double altitudeIntegral = GetFsxData(FsxDataOffset.AircraftAltitudeIntegral); double altitudeFractional = GetFsxData(FsxDataOffset.AircraftAltitudeFractional); return PositionCalculator.CalculatePosition(latitudeLow, latitudeHigh, longitudeLow, longitudeHigh, altitudeIntegral, altitudeFractional); })); }
public KaraokeHitObjectComposer(Ruleset ruleset) : base(ruleset) { // Duplicated registration because selection handler need to use it. positionCalculator = new PositionCalculator(9); editConfigManager = new KaraokeRulesetEditConfigManager(); generatorConfigManager = new KaraokeRulesetEditGeneratorConfigManager(); checkerConfigManager = new KaraokeRulesetEditCheckerConfigManager(); AddInternal(exportLyricManager = new ExportLyricManager()); AddInternal(noteManager = new NoteManager()); AddInternal(lyricManager = new LyricManager()); AddInternal(lyricCheckerManager = new LyricCheckerManager()); AddInternal(singerManager = new SingerManager()); LayerBelowRuleset.Add(languageSelectionDialog = new LanguageSelectionDialog()); }
static int Main(string[] args) { if (args.Length < 1) { Console.WriteLine("Usage: dotnet run <input_file_full_path>"); return(-1); } string inputfile = args[0]; IEnumerable <Position> inputPositions = null; try { inputPositions = parseInputFile(inputfile); } catch (IOException ioe) { Console.WriteLine("IOException while processing input files {0}", inputfile); Console.WriteLine("StackTrace: {0} ", ioe.StackTrace); return(-1); } catch (Exception e) { Console.WriteLine("The program has encountered an unexpected error"); Console.WriteLine("StackTrace: {0} ", e.StackTrace); return(-1); } PositionCalculator positionCalculator = new PositionCalculator(); IEnumerable <NetPosition> netPositions = positionCalculator.calculateNetPositions(inputPositions); IEnumerable <BoxedPosition> boxedPositions = positionCalculator.calculateBoxedPositions(inputPositions); Console.WriteLine("Net Positions: \n"); outputNetPositions(netPositions); Console.WriteLine("\n\nBox Positions: \n"); outputBoxedPositions(boxedPositions); return(0); }
public NotePlayfieldPreview() { Size = new Vector2(0.7f, 0.5f); positionCalculator = new PositionCalculator(row_amount); scrollingInfo = new LocalScrollingInfo(); Child = new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding(30), Child = notePlayfield = new NotePlayfield(row_amount) { Anchor = Anchor.Centre, Origin = Anchor.Centre, } }; }
void AddTextCoordinatesOnGrid(int width, int height) { for (int z = 0, i = 0; z < height; z++) { for (int x = 0; x < width; x++) { Text label = Instantiate <Text>(cellLabelPrefab); label.rectTransform.SetParent(gridCanvas.transform, false); label.rectTransform.anchoredPosition = new Vector2( PositionCalculator.GetPositionX(x, z), PositionCalculator.GetPositionZ(z) ); HexCoordinates coordinates = CoordinatesService.CreateFromOffset(x, z); label.text = "" + coordinates.Value.x + ", " + coordinates.Value.y + ", " + coordinates.Value.z + ""; } } }
public void Test1() { const double ROBOT_WIDTH = 124.0; const double WHEEL_RADIUS = 33.2; const int ENCODER_POINTS = 20; var calculator = new PositionCalculator(ROBOT_WIDTH, WHEEL_RADIUS, ENCODER_POINTS); var robot = new Robot(); var start = DateTime.Now; for (var i = 1; i <= 10; i++) { calculator.Signal(Encoder.Left, i, (long)(DateTime.Now - start).TotalMilliseconds); Task.Delay(10).Wait(); calculator.Signal(Encoder.Right, i, (long)(DateTime.Now - start).TotalMilliseconds); Task.Delay(90).Wait(); } Assert.Pass(); }
public static async Task <PositionHistory> GetPositionHistory(string currency) { currency = currency.ToUpper(); CurrencyPair currencyPair; if (CurrencyPair.IsCurrencyPair(currency)) { currencyPair = currency; } else { currencyPair = CurrencyPair.PrependBitcoin(currency); } var authenticator = new Authenticator( "F5QR8MJE-HN5LH4WJ-8X9758YH-NDLRE7NJ", "0be35048de6102dfa9927504b4099aac222636f2dd96983f9713fe0c9b93d489f38ae08d9e3e3b4b3509ef77c182f9000a4b8b21c49d8af84ad0863c6937f932"); var client = new ApiHttpClient(authenticator); var trades = await client.Trading.GetTrades(currencyPair, DateTime.Parse("1/1/2008"), DateTime.UtcNow); var balances = await client.Wallet.GetCompleteBalances(); //var currentTick = Ticker.Current[currencyPair]; //var currentPrice = currentTick.Last; var balance = balances[currencyPair.QuoteCurrency]; var balanceSize = balance.Available + balance.OnOrders; var currentValue = balance.BtcValue; var calculatedCurrentPrice = balance.BtcValue / balanceSize; var roundedCalculatedCurrentPrice = Math.Round(calculatedCurrentPrice, 8); var positionHistory = PositionCalculator.ExtractPositions(balanceSize, roundedCalculatedCurrentPrice, trades); return(positionHistory); }
public DrawableKaraokeRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList <Mod> mods) : base(ruleset, beatmap, mods) { positionCalculator = new PositionCalculator(9); // TODO : it should be moved into NotePlayfield BarLines = new BarLineGenerator <BarLine>(Beatmap).BarLines; // Editor should not generate hud overlay if (mods == null) { return; } // create overlay var overlay = new KaraokeHUDOverlay(this); foreach (var mod in mods.OfType <IApplicableToKaraokeHUD>()) { mod.ApplyToKaraokeHUD(overlay); } Overlays.Add(overlay); }
public override void Render(Entity entity) { transform.DOMove(PositionCalculator.Calculate(entity.Get <PositionComponent>().Value), 0.1f); }
private void DecodeSkeletonData(AllFramesReadyEventArgs e, KinectSensor sensor) { #region GetImageFormat ColorImageFormat colorFormat = ColorImageFormat.Undefined; int colorWidth = 0; int colorHeight = 0; DepthImageFormat depthFormat = DepthImageFormat.Undefined; int depthWidth = 0; int depthHeight = 0; switch (this._imageType) { case ImageType.Color: // Retrieve the current color format, from the frame if present, and from the sensor if not. using (ColorImageFrame colorImageFrame = e.OpenColorImageFrame()) { if (null != colorImageFrame) { colorFormat = colorImageFrame.Format; colorWidth = colorImageFrame.Width; colorHeight = colorImageFrame.Height; } else if (null != sensor.ColorStream) { colorFormat = sensor.ColorStream.Format; colorWidth = sensor.ColorStream.FrameWidth; colorHeight = sensor.ColorStream.FrameHeight; } } break; case ImageType.Depth: // Retrieve the current depth format, from the frame if present, and from the sensor if not. using (DepthImageFrame depthImageFrame = e.OpenDepthImageFrame()) { if (null != depthImageFrame) { depthFormat = depthImageFrame.Format; depthWidth = depthImageFrame.Width; depthHeight = depthImageFrame.Height; } else if (null != sensor.DepthStream) { depthFormat = sensor.DepthStream.Format; depthWidth = sensor.DepthStream.FrameWidth; depthHeight = sensor.DepthStream.FrameHeight; } } break; } #endregion // Clear the play canvas this.playField.Children.Clear(); // Check every skeleton for (int skeletonSlot = 0; skeletonSlot < this._skeletonBuffer.Length; skeletonSlot++) { var skeleton = this._skeletonBuffer[skeletonSlot]; #region Skeleton Position // Map points between skeleton and color/depth var jointMapping = this._jointMappings[skeletonSlot]; jointMapping.Clear(); try { // Transform the data into the correct space // For each joint, we determine the exact X/Y coordinates for the target view foreach (Joint joint in skeleton.Joints) { ColorImagePoint colorPoint = sensor.CoordinateMapper.MapSkeletonPointToColorPoint(joint.Position, colorFormat); Point mappedPoint = new Point( (int)(this._renderSize.Width * colorPoint.X / colorWidth), (int)(this._renderSize.Height * colorPoint.Y / colorHeight)); jointMapping[joint.JointType] = new JointMapping { Joint = joint, MappedPoint = mappedPoint, OriginPoint = colorPoint, }; } } catch (UnauthorizedAccessException) { // Kinect is no longer available. return; } // Look up the center point Point centerPoint = PositionCalculator.Get2DPosition( sensor, this._imageType, this._renderSize, skeleton.Position, colorFormat, colorWidth, colorHeight, depthFormat, depthWidth, depthHeight); #endregion // Scale the skeleton thickness // 1.0 is the desired size at 640 width this._scaleFactor = this._renderSize.Width / colorWidth; // Displays a gradient near the edge of the display // where the skeleton is leaving the screen this.DrawClippedEdges(skeleton); switch (skeleton.TrackingState) { case SkeletonTrackingState.PositionOnly: { // The skeleton is being tracked, but we only know the general position, and // we do not know the specific joint locations. this.DrawBodyCenter(centerPoint); } break; case SkeletonTrackingState.Tracked: { // The skeleton is being tracked and the joint data is available for consumption. this.DrawBody(skeleton, jointMapping); // Track player this.TrackPlayer(skeleton, jointMapping); } break; } } }
public PositionCalculatorTests() { positionCalculator = new PositionCalculator(); }
public Service() { this.statisticProvider = new StatisticProvider(); this.posCalculator = new PositionCalculator(); }
public KaraokeHitObjectComposer(Ruleset ruleset) : base(ruleset) { // Duplicated registration because selection handler need to use it. positionCalculator = new PositionCalculator(9); }
public HomeService(IReadOnlyList <CrimesServiceClient> agents, PositionCalculator calculator, IStatisticProvider statisticProvider) { this.agents = agents; this.calculator = calculator; this.statisticProvider = statisticProvider; }