public override void CalcPosInfo(int time) { //base.CalcPosInfo(time); //? //todo null-sjekk Canvas c = (Canvas)infoShape.Parent; int scaledOrbitRadius = SpaceScalingHelper.OrbitalRadiusInfoScaling(c.RenderSize.Width, OrbitalRadius); int slowDown = 200; //todo fiks slowdown if (OrbitalRadius < 100) { slowDown = 5500; } slowDown = SpaceScalingHelper.CalcSlowDown(OrbitalRadius, OrbitalPeriod); XPos = (int)(c.RenderSize.Width / 2 - infoShape.Width / 2 + scaledOrbitRadius * Math.Cos(time * (2 * 3.1416 * scaledOrbitRadius / OrbitalPeriod) / slowDown)); YPos = (int)(c.RenderSize.Height / 2 - infoShape.Height / 2 + scaledOrbitRadius * -Math.Sin(time * (2 * 3.1416 * scaledOrbitRadius / OrbitalPeriod) / slowDown)); orbit.Width = scaledOrbitRadius * 2; orbit.Height = scaledOrbitRadius * 2; //todo null-sjekk Canvas.SetLeft(orbit, c.RenderSize.Width / 2 - scaledOrbitRadius); Canvas.SetTop(orbit, c.RenderSize.Height / 2 - scaledOrbitRadius); Canvas.SetLeft(infoShape, XPos); Canvas.SetTop(infoShape, YPos); Canvas.SetLeft(infoText, XPos + infoShape.Width / 2); Canvas.SetTop(infoText, YPos + infoShape.Height); }
public override void CalcPos(int time) { Canvas c = (Canvas)shape.Parent; int scaledOrbitRadius = SpaceScalingHelper.OrbitalRadiusScaling(c.RenderSize.Width, OrbitalRadius); //fart er 2*PI*R/T XPos = (int)(c.RenderSize.Width / 2 - shape.Width / 2 + scaledOrbitRadius * Math.Cos(time * (2 * 3.1416 * scaledOrbitRadius / OrbitalPeriod) / 30)); YPos = (int)(c.RenderSize.Height / 2 - shape.Height / 2 + scaledOrbitRadius * -Math.Sin(time * (2 * 3.1416 * scaledOrbitRadius / OrbitalPeriod) / 30)); //TODO må ha noko skalering her orbit.Width = scaledOrbitRadius * 2; orbit.Height = scaledOrbitRadius * 2; Canvas.SetLeft(orbit, c.RenderSize.Width / 2 - scaledOrbitRadius); Canvas.SetTop(orbit, c.RenderSize.Height / 2 - scaledOrbitRadius); Canvas.SetLeft(shape, XPos); Canvas.SetTop(shape, YPos); Canvas.SetLeft(shapeText, XPos + shape.Width / 2); Canvas.SetTop(shapeText, YPos + shape.Height); }