public void RenderIcons(PerspectiveCamera viewPoint, GBuffer gBuffer) { this.Effect.World = Matrix.Identity; this.Effect.View = Matrix.Identity; this.Effect.Projection = Matrix.Identity; this.Effect.DepthMap = gBuffer.DepthTarget; this.Device.PostProcessState(); for (var i = 0; i < this.Components.Count; i++) { var component = this.Components[i]; var pose = this.Poses.Get(component.Entity); var position = pose.Position; if (viewPoint.Frustum.Contains(position) != ContainmentType.Disjoint) { var screenPosition = ProjectionMath.WorldToView(position, viewPoint.ViewProjection); this.Effect.World = Matrix.CreateScale(new Vector3(IconScale / viewPoint.AspectRatio, IconScale, IconScale)) * Matrix.CreateTranslation(new Vector3(screenPosition, 0)); this.Effect.Texture = this.Library.GetIcon(component.Icon); this.Effect.WorldPosition = position; this.Effect.CameraPosition = viewPoint.Position; this.Effect.InverseViewProjection = viewPoint.InverseViewProjection; this.Effect.VisibleTint = component.BoundaryVisibleTint; this.Effect.ClippedTint = component.BoundaryClippedTint; this.Effect.Apply(TextureEffectTechniques.TexturePointDepthTest); this.Quad.Render(); } } }
public GnomonicAzimuthalProjection(double projectionLatitude, double projectionLongitude) : base(projectionLatitude, projectionLongitude) { MinLatitude = ProjectionMath.ToRadians(0); MaxLatitude = ProjectionMath.ToRadians(90); Initialize(); }
public override Coordinate ProjectInverse(double xyx, double xyy, Coordinate lp) { double rho; rho = ProjectionMath.Distance(xyx, lp.Y = _rho0 - xyy); if (_n < 0.0) { rho = -rho; lp.X = -xyx; lp.Y = -xyy; } lp.X = Math.Atan2(xyx, xyy) / _n; switch (ConicType) { case ConicTypes.PerspectiveConic: lp.Y = Math.Atan(_c1 - rho / _c2) + _sig; break; case ConicTypes.Murdoch2: lp.Y = _sig - Math.Atan(rho - _rhoC); break; default: lp.Y = _rhoC - rho; break; } return(lp); }
public override Coordinate ProjectInverse(double xyx, double xyy, Coordinate coord) { double t, r, rp, rl, al, z = 0, fAz, Az, s, c, Av; Boolean neg; int i; if (noskew) { t = xyx; coord.X = -xyx * cAzc + xyy * sAzc; coord.Y = -xyy * cAzc - t * sAzc; } if (neg = (xyx < 0.0)) { coord.Y = rhoc - xyy; s = S20; c = C20; Av = Azab; } else { coord.Y += rhoc; s = S45; c = C45; Av = Azba; } rl = rp = r = ProjectionMath.Distance(xyx, xyy); fAz = Math.Abs(Az = Math.Atan2(xyx, xyy)); for (i = NITER; i > 0; --i) { z = 2.0 * Math.Atan(Math.Pow(r / F, 1 / n)); al = Math.Acos((Math.Pow(Math.Tan(.5 * z), n) + Math.Pow(Math.Tan(.5 * (R104 - z)), n)) / T); if (fAz < al) { r = rp * Math.Cos(al + (neg ? Az : -Az)); } if (Math.Abs(rl - r) < EPS) { break; } rl = r; } if (i == 0) { throw new ProjectionException("I"); } Az = Av - Az / n; coord.Y = Math.Asin(s * Math.Cos(z) + c * Math.Sin(z) * Math.Cos(Az)); coord.X = Math.Atan2(Math.Sin(Az), c / Math.Tan(z) - s * Math.Cos(Az)); if (neg) { coord.X -= R110; } else { coord.X = lamB - coord.X; } return(coord); }
public override Coordinate ProjectInverse(double xyx, double xyy, Coordinate coord) { if (_spherical) { coord.Y = Math.Asin(Math.Asin(_dd = xyy + ProjectionLatitude) * Math.Cos(xyx)); coord.X = Math.Atan2(Math.Tan(xyx), Math.Cos(_dd)); } else { double ph1; ph1 = ProjectionMath.inv_mlfn(_m0 + xyy, _es, _en); _tn = Math.Tan(ph1); _t = _tn * _tn; _n = Math.Sin(ph1); _r = 1.0 / (1.0 - _es * _n * _n); _n = Math.Sqrt(_r); _r *= (1.0 - _es) * _n; _dd = xyx / _n; _d2 = _dd * _dd; coord.Y = ph1 - (_n * _tn / _r) * _d2 * (.5 - (1.0 + 3.0 * _t) * _d2 * C3); coord.X = _dd * (1.0 + _t * _d2 * (-C4 + (1.0 + 3.0 * _t) * _d2 * C5)) / Math.Cos(ph1); } return(coord); }
public override Coordinate ProjectInverse(double xyx, double xyy, Coordinate lp) { double V; int i; if (n != 0) { lp.Y = xyy; for (i = MaxIter; i > 0; --i) { lp.Y -= V = (n * lp.Y + n1 * Math.Sin(lp.Y) - xyy) / (n + n1 * Math.Cos(lp.Y)); if (Math.Abs(V) < LoopTolerance) { break; } } if (i == 0) { lp.Y = xyy < 0.0 ? -ProjectionMath.PiHalf : ProjectionMath.PiHalf; } } else { lp.Y = ProjectionMath.Asin(xyy); } V = Math.Cos(lp.Y); lp.X = xyx * (n + n1 * V) / V; return(lp); }
public override Coordinate ProjectInverse(double xyx, double xyy, Coordinate lp) { xyy /= C_y; lp.Y = ProjectionMath.Asin(Math.Sin(xyy) / n); lp.X = xyx / (C_x * Math.Cos(xyy)); return(lp); }
public override Coordinate Project(double lplam, double lpphi, Coordinate xy) { xy.Y = ProjectionMath.Asin(n * Math.Sin(lpphi)); xy.X = C_x * lplam * Math.Cos(lpphi); xy.Y = C_y * lpphi; return(xy); }
public override Coordinate ProjectInverse(double x, double y, Coordinate lp) { int i; double t, t1; lp.X = x / FXC; lp.Y = Math.Abs(y / FYC); if (lp.Y >= 1.0) { if (lp.Y > 1.000001) { throw new ProjectionException(); } else { lp.Y = y < 0.0 ? -ProjectionMath.PiHalf : ProjectionMath.PiHalf; lp.X /= X[4 * NODES]; } } else { for (i = 4 * (int)Math.Floor(lp.Y * NODES); ;) { if (Y[i] > lp.Y) { i -= 4; } else if (Y[i + 4] <= lp.Y) { i += 4; } else { break; } } t = 5.0 * (lp.Y - Y[i]) / (Y[i + 4] - Y[i]); double Tc0 = Y[i]; double Tc1 = Y[i + 1]; double Tc2 = Y[i + 2]; double Tc3 = Y[i + 3]; t = 5.0 * (lp.Y - Tc0) / (Y[i + 1] - Tc0); Tc0 -= lp.Y; for (; ;) { // Newton-Raphson t -= t1 = (Tc0 + t * (Tc1 + t * (Tc2 + t * Tc3))) / (Tc1 + t * (Tc2 + Tc2 + t * 3.0 * Tc3)); if (Math.Abs(t1) < EPS) { break; } } lp.Y = ProjectionMath.ToRadians(5 * i + t); if (y < 0.0) { lp.Y = -lp.Y; } lp.X /= poly(X, i, t); } return(lp); }
public override Coordinate Project(double lplam, double lpphi, Coordinate coord) { if (_spherical) { double E, rh; rh = _cphi1 + _phi1 - lpphi; if (Math.Abs(rh) > EPS10) { coord.X = rh * Math.Sin(E = lplam * Math.Cos(lpphi) / rh); coord.Y = _cphi1 - rh * Math.Cos(E); } else { coord.X = coord.Y = 0.0; } } else { double E = Math.Sin(lpphi), c = Math.Cos(lpphi); double rh = _am1 + _m1 - ProjectionMath.mlfn(lpphi, E, c, _en); E = c * lplam / (rh * Math.Sqrt(1.0 - _es * E * E)); coord.X = rh * Math.Sin(E); coord.Y = _am1 - rh * Math.Cos(E); } return(coord); }
public override Coordinate ProjectInverse(double x, double y, Coordinate lp) { if (Spherical) { double t; if ((t = Math.Abs(y *= ScaleFactor)) - EPS10 <= 1.0) { if (t >= 1.0) { lp.Y = y < 0.0 ? -ProjectionMath.PiHalf : ProjectionMath.PiHalf; } else { lp.Y = Math.Asin(y); } lp.X = x / ScaleFactor; } else { throw new ProjectionException(); } } else { lp.Y = ProjectionMath.AuthLat(Math.Asin(2.0 * y * ScaleFactor / _qp), _apa); lp.X = x / ScaleFactor; } return(lp); }
public void RenderProjectors(PerspectiveCamera perspectiveCamera, GBuffer gBuffer) { this.Device.PostProcessState(); for (var i = 0; i < this.Projectors.Count; i++) { var projector = this.Projectors[i]; if (projector.ViewPoint.Frustum.Intersects(perspectiveCamera.Frustum)) { //G-Buffer input this.Effect.DepthMap = gBuffer.DepthTarget; // Projector properties this.Effect.ProjectorMap = projector.Texture; this.Effect.Mask = projector.Mask; this.Effect.ProjectorViewProjection = projector.ViewPoint.ViewProjection; this.Effect.MaxDistance = projector.MaxDistance; this.Effect.ProjectorPosition = projector.ViewPoint.Position; this.Effect.ProjectorForward = projector.ViewPoint.Forward; this.Effect.Tint = projector.Tint; // Camera properties this.Effect.World = Matrix.Identity; this.Effect.View = perspectiveCamera.View; this.Effect.Projection = ProjectionMath.ComputeProjectionMatrixThatFitsFrustum(perspectiveCamera, projector.ViewPoint.Frustum); this.Effect.InverseViewProjection = perspectiveCamera.InverseViewProjection; this.Effect.Apply(this.Technique); this.FrustumDrawer.Render(projector.ViewPoint.Frustum); } } }
public override void Initialize() { base.Initialize(); double c; //_phi1 = pj_param(params, "rlat_1").f; _phi1 = ProjectionMath.PiHalf; if (Math.Abs(_phi1) < EPS10) { throw new ProjectionException("-23"); } if (!_spherical) { _en = ProjectionMath.enfn(_es); _m1 = ProjectionMath.mlfn(_phi1, _am1 = Math.Sin(_phi1), c = Math.Cos(_phi1), _en); _am1 = c / (Math.Sqrt(1.0 - _es * _am1 * _am1) * _am1); } else { if (Math.Abs(_phi1) + EPS10 >= ProjectionMath.PiHalf) { _cphi1 = 0.0; } else { _cphi1 = 1.0 / Math.Tan(_phi1); } } }
public void RenderIcons(PerspectiveCamera viewPoint, GBuffer gBuffer) { this.Effect.World = Matrix.Identity; this.Effect.View = Matrix.Identity; this.Effect.Projection = Matrix.Identity; this.Effect.DepthMap = gBuffer.DepthTarget; this.Device.PostProcessState(); foreach ((var entity, var component, var info, var property, var attribute) in this.EnumerateAttributes <IconAttribute>()) { var position = (Vector3)property.GetGetMethod().Invoke(component, null); if (viewPoint.Frustum.Contains(position) != ContainmentType.Disjoint) { var screenPosition = ProjectionMath.WorldToView(position, viewPoint.ViewProjection); this.Effect.World = Matrix.CreateScale(new Vector3(Scale / viewPoint.AspectRatio, Scale, Scale)) * Matrix.CreateTranslation(new Vector3(screenPosition, 0)); this.Effect.Texture = this.Library.GetIcon(attribute.Type); this.Effect.WorldPosition = position; this.Effect.CameraPosition = viewPoint.Position; this.Effect.InverseViewProjection = viewPoint.InverseViewProjection; this.Effect.VisibleTint = info.VisibileIconTint; this.Effect.ClippedTint = info.ClippedIconTint; this.Effect.Apply(TextureEffectTechniques.TexturePointDepthTest); this.Quad.Render(); } } }
///<summary> /// Inverse-projects a point (in the units defined by the coordinate system), /// producing a geographic result (in radians) ///</summary> /// <param name="src">the input projected coordinate (in coordinate system units)</param> /// <param name="dst">the inverse-projected geographic coordinate (in radians)</param> /// <returns>the target coordinate</returns> public Coordinate InverseProjectRadians(Coordinate src, Coordinate dst) { double x; double y; if (_unit == Units.Units.Degrees) { // convert DD to radians x = src.X * DTR; y = src.Y * DTR; } else { x = (src.X - _totalFalseEasting) / _totalScale; y = (src.Y - _totalFalseNorthing) / _totalScale; } ProjectInverse(x, y, dst); if (dst.X < -Math.PI) { dst.X = -Math.PI; } else if (dst.X > Math.PI) { dst.X = Math.PI; } if (_projectionLongitude != 0) { dst.X = ProjectionMath.NormalizeLongitude(dst.X + _projectionLongitude); } return(dst); }
internal override bool ReadHeader(GridTable table) { using (var sr = new StreamReader(OpenGridTableStream())) { table.Name = sr.ReadLine(); var definition = sr.ReadLine(); if (string.IsNullOrEmpty(definition)) { return(false); } var definitionParts = definition.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); table.NumLambdas = int.Parse(definitionParts[0], NumberStyles.Integer); table.NumPhis = int.Parse(definitionParts[0], NumberStyles.Integer); table.LowerLeft = new PhiLambda { Lambda = ProjectionMath.ToRadians(double.Parse(definitionParts[3], CultureInfo.InvariantCulture)), Phi = ProjectionMath.ToRadians(double.Parse(definitionParts[5], CultureInfo.InvariantCulture)) }; table.SizeOfGridCell = new PhiLambda { Lambda = ProjectionMath.ToRadians(double.Parse(definitionParts[4], CultureInfo.InvariantCulture)), Phi = ProjectionMath.ToRadians(double.Parse(definitionParts[6], CultureInfo.InvariantCulture)) }; table.UpperRight = table.LowerLeft + table.SizeOfGridCell.Times(table.NumPhis, table.NumLambdas); return(true); } }
public override Coordinate ProjectInverse(double x, double y, Coordinate coord) { x /= ScaleFactor; y /= ScaleFactor; double rho = ProjectionMath.Distance(x, y = rho0 - y); if (rho != 0) { if (n < 0.0) { rho = -rho; x = -x; y = -y; } if (Spherical) { coord.Y = 2.0 * Math.Atan(Math.Pow(c / rho, 1.0 / n)) - ProjectionMath.PiHalf; } else { coord.Y = ProjectionMath.Phi2(Math.Pow(rho / c, 1.0 / n), Eccentricity); } coord.X = Math.Atan2(x, y) / n; } else { coord.X = 0.0; coord.Y = n > 0.0 ? ProjectionMath.PiHalf : -ProjectionMath.PiHalf; } return(coord); }
public override Coordinate ProjectInverse(double xyx, double xyy, Coordinate lp) { lp.Y = xyy / C_y; lp.X = xyx / (C_x * Math.Cos(lp.Y)); lp.Y = ProjectionMath.Asin(Math.Sin(lp.Y) / C_p1) / C_p2; return(lp); }
public static PhiLambda ArcMicroSecondsToRadians(double phi, double lambda) { return(new PhiLambda { Lambda = ProjectionMath.ArcMicroSecondsToRadians(lambda), Phi = ProjectionMath.ArcMicroSecondsToRadians(phi) }); }
public CassiniProjection() { ProjectionLatitude = ProjectionMath.ToRadians(0); ProjectionLongitude = ProjectionMath.ToRadians(0); MinLongitude = ProjectionMath.ToRadians(-90); MaxLongitude = ProjectionMath.ToRadians(90); Initialize(); }
public PolyconicProjection() { MinLatitude = ProjectionMath.ToRadians(0); MaxLatitude = ProjectionMath.ToRadians(80); MinLongitude = ProjectionMath.ToRadians(-60); MaxLongitude = ProjectionMath.ToRadians(60); Initialize(); }
public BipolarProjection() { MinLatitude = ProjectionMath.ToRadians(-80); MaxLatitude = ProjectionMath.ToRadians(80); ProjectionLongitude = ProjectionMath.ToRadians(-90); MinLongitude = ProjectionMath.ToRadians(-90); MaxLongitude = ProjectionMath.ToRadians(90); }
public override Coordinate ProjectInverse(double xyx, double xyy, Coordinate lp) { double th, s; lp.X = 2.0 * xyx / (1.0 + Math.Cos(xyy)); lp.Y = ProjectionMath.Asin(0.5 * (xyy + Math.Sin(xyy))); return(lp); }
public LambertEqualAreaConicProjection(Boolean south) { MinLatitude = ProjectionMath.ToRadians(0); MaxLatitude = ProjectionMath.ToRadians(90); ProjectionLatitude1 = south ? -ProjectionMath.QuarterPI : ProjectionMath.QuarterPI; ProjectionLatitude2 = south ? -ProjectionMath.HalfPI : ProjectionMath.HalfPI; Initialize(); }
public override Coordinate Project(double lplam, double lpphi, Coordinate xy) { lpphi = ProjectionMath.Asin(0.883883476 * Math.Sin(lpphi)); xy.X = C_x * lplam * Math.Cos(lpphi); xy.X /= Math.Cos(lpphi *= 0.333333333333333); xy.Y = C_y * Math.Sin(lpphi); return(xy); }
//protected double projectionLatitude1 = MapMath.degToRad(45.5); //protected double projectionLatitude2 = MapMath.degToRad(29.5); public AlbersProjection() { MinLatitude = ProjectionMath.ToRadians(0); MaxLatitude = ProjectionMath.ToRadians(80); ProjectionLatitude1 = ProjectionMath.ToRadians(45.5); ProjectionLatitude2 = ProjectionMath.ToRadians(29.5); Initialize(); }
public LambertEqualAreaConicProjection(Boolean south) { MinLatitude = ProjectionMath.ToRadians(0); MaxLatitude = ProjectionMath.ToRadians(90); ProjectionLatitude1 = south ? -ProjectionMath.PiFourth : ProjectionMath.PiFourth; ProjectionLatitude2 = south ? -ProjectionMath.PiHalf : ProjectionMath.PiHalf; Initialize(); }
// ReSharper restore InconsistentNaming public AiryProjection() { _minLatitude = ProjectionMath.ToRadians(-60); _maxLatitude = ProjectionMath.ToRadians(60); _minLongitude = ProjectionMath.ToRadians(-90); _maxLongitude = ProjectionMath.ToRadians(90); Initialize(); }
public static PhiLambda ArcMicroSecondsToRadians(PhiLambda plInDegrees) { return(new PhiLambda { Lambda = ProjectionMath.ArcMicroSecondsToRadians(plInDegrees.Lambda), Phi = ProjectionMath.ArcMicroSecondsToRadians(plInDegrees.Phi) }); }
public override Coordinate ProjectInverse(double xyx, double xyy, Coordinate lp) { lp.Y = ProjectionMath.Asin(xyy / C_y); lp.X = xyx * Math.Cos(lp.Y) / C_x; lp.Y *= 3.0; lp.X /= Math.Cos(lp.Y); lp.Y = ProjectionMath.Asin(1.13137085 * Math.Sin(lp.Y)); return(lp); }