Beispiel #1
0
FlatPoint
FlatProjection::ProjectFloat(const GeoPoint &tp) const
{
    assert(IsValid());

    return FlatPoint((tp.longitude - center.longitude)
                     .AsDelta().Native() * cos,
                     (tp.latitude - center.latitude)
                     .AsDelta().Native() * fixed_scale);
}
Beispiel #2
0
FlatPoint
TaskProjection::fproject(const GeoPoint& tp) const
{
  assert(initialised);

  return FlatPoint((tp.Longitude - location_mid.Longitude)
                   .as_delta().value_native() * cos_midloc,
                   (tp.Latitude - location_mid.Latitude)
                   .as_delta().value_native() * fixed_scale);
}
Beispiel #3
0
/**
 * Convert a #LeastSquares to a #WaveInfo.  Returns
 * WaveInfo::Undefined() if there is no valid result in the
 * #LeastSquares instance.
 */
gcc_pure
static WaveInfo
GetWaveInfo(const LeastSquares &ls, const FlatProjection &projection,
            double time)
{
  if (!ls.HasResult())
    return WaveInfo::Undefined();

  const FlatPoint flat_location(ls.GetMiddleX(), ls.GetAverageY());
  const GeoPoint location(projection.Unproject(flat_location));

  const GeoPoint a(projection.Unproject(FlatPoint(ls.GetMinX(),
                                                  ls.GetYAtMinX())));
  const GeoPoint b(projection.Unproject(FlatPoint(ls.GetMaxX(),
                                                  ls.GetYAtMaxX())));

  Angle bearing = a.Bearing(b);
  Angle normal = (bearing + Angle::QuarterCircle()).AsBearing();

  return {location, a, b, normal, time};
}
Beispiel #4
0
bool
FlatEllipse::intersect_extended(const FlatPoint &pe, FlatPoint &i1,
                                FlatPoint &i2) const
{
  const FlatLine l_f1p(f1, pe);
  const FlatLine l_pf2(pe, f2);
  const Angle ang = l_f1p.angle();

  const fixed d = l_pf2.d() + max(a, b); // max line length

  fixed can, san;
  ang.sin_cos(san, can);

  FlatLine e_l(pe, FlatPoint(pe.x + d * can, pe.y + d * san));
  // e_l is the line extended from p in direction of f1-p 
  
  return intersect(e_l, i1, i2);
}
Beispiel #5
0
bool
FlatEllipse::IntersectExtended(const FlatPoint &pe, FlatPoint &i1,
                                FlatPoint &i2) const
{
  const FlatLine l_f1p(f1, pe);
  const FlatLine l_pf2(pe, f2);
  const Angle ang = l_f1p.angle();

  const fixed d = l_pf2.d() + std::max(a, b); // max line length

  const auto sc = ang.SinCos();
  fixed san = sc.first, can = sc.second;

  FlatLine e_l(pe, FlatPoint(pe.x + d * can, pe.y + d * san));
  // e_l is the line extended from p in direction of f1-p 
  
  return Intersect(e_l, i1, i2);
}
Beispiel #6
0
 constexpr
 FlatPoint Half() const {
   return FlatPoint(::Half(x), ::Half(y));
 }
Beispiel #7
0
 gcc_constexpr_method
 FlatPoint Half() const {
   return FlatPoint(::half(x), ::half(y));
 }
Beispiel #8
0
 constexpr
 FlatPoint Half() const {
   return FlatPoint(x / 2, y / 2);
 }