Beispiel #1
0
bool
OrderedTaskPoint::CheckEnterTransition(const AircraftState &ref_now,
                                       const AircraftState &ref_last) const
{
  return IsInSector(ref_now) && !IsInSector(ref_last) &&
    TransitionConstraint(ref_now.location, ref_last.location);
}
Beispiel #2
0
void GetEnclosingRectangleOfSector(Sector* sector, Point* down_left, Point* up_right)
{
	Point center_of_arc = GetCenterInArcOfSector(sector);
	float vx = center_of_arc.x - sector->c.c.x;
	float vy = center_of_arc.y - sector->c.c.y;
	float h = sector->r * 0.5f;
	float c = cosf(h);
	float s = sinf(h);
	Point vertex_a = { sector->c.c.x + (vx * c - vy * s), sector->c.c.y + (vy * c + vx * s) };
	Point vertex_b = { sector->c.c.x + (vx * c + vy * s), sector->c.c.y + (vy * c - vx * s) };

	Point up = { sector->c.c.x, sector->c.c.y + sector->c.r };
	Point down = { sector->c.c.x, sector->c.c.y - sector->c.r };
	Point left = { sector->c.c.x - sector->c.r, sector->c.c.y };
	Point right = { sector->c.c.x + sector->c.r, sector->c.c.y };

	up_right->y = IsInSector(up, sector) ? up.y : MAX(MAX(vertex_a.y, vertex_b.y), sector->c.c.y);
	down_left->y = IsInSector(down, sector) ? down.y : MIN(MIN(vertex_a.y, vertex_b.y), sector->c.c.y);
	up_right->x = IsInSector(right, sector) ? right.x : MAX(MAX(vertex_a.x, vertex_b.x), sector->c.c.x);
	down_left->x = IsInSector(left, sector) ? left.x : MIN(MIN(vertex_a.x, vertex_b.x), sector->c.c.x);

	PrintPoint(center_of_arc, "black");
	PrintPoint(sector->c.c, "black");
	PrintPoint(vertex_a, "black");
	PrintPoint(vertex_b, "black");

	PrintPoint(up, IsInSector(up, sector) ? "red" : "yellow");
	PrintPoint(down, IsInSector(down, sector) ? "red" : "yellow");
	PrintPoint(left, IsInSector(left, sector) ? "red" : "yellow");
	PrintPoint(right, IsInSector(right, sector) ? "red" : "yellow");
}
Beispiel #3
0
bool 
SampledTaskPoint::UpdateSampleNear(const AircraftState& state,
                                     const TaskProjection &projection)
{
  if (!IsInSector(state))
    // return false (no update required)
    return false;

  // if sample is inside sample polygon
  if (sampled_points.IsInside(state.location))
    // return false (no update required)
    return false;

  // add sample to polygon
  SearchPoint sp(state.location, projection);
  sampled_points.push_back(sp);

  // re-compute convex hull
  bool retval = sampled_points.PruneInterior();

  // only return true if hull changed
  // return true; (update required)
  return sampled_points.ThinToSize(64) || retval;

  // thin to size is used here to ensure the sampled points vector
  // size is bounded to reasonable values for AAT calculations.
}
Beispiel #4
0
bool
OrderedTaskPoint::UpdateSampleNear(const AircraftState &state,
                                   const TaskProjection &projection)
{
  if (!IsInSector(state))
    // return false (no update required)
    return false;

  return AddInsideSample(state, projection);
}
Beispiel #5
0
bool 
StartPoint::UpdateSampleNear(const AircraftState& state,
                             TaskEvents *task_events,
                               const TaskProjection &projection)
{
  if (task_events != NULL && IsInSector(state) &&
      !ordered_task_behaviour.CheckStartSpeed(state, margins))
    task_events->StartSpeedWarning();

  return OrderedTaskPoint::UpdateSampleNear(state, task_events, projection);
}
Beispiel #6
0
GeoPoint
CylinderZone::randomPointInSector(const fixed mag) const
{
  AircraftState ac;
  do {
    Angle dir = Angle::degrees(fixed(rand() % 360));
    fixed dmag = max(min(Radius, fixed(100.0)), Radius * mag);
    fixed dis = fixed((0.1 + (rand() % 90) / 100.0)) * dmag;
    GeoVector vec(dis, dir);
    ac.location = vec.end_point(get_location());
  } while (!IsInSector(ac));
  return ac.location;
}
Beispiel #7
0
bool
AATPoint::CheckTarget(const AircraftState &state, const bool known_outside)
{
  if (IsCurrent() && target_locked)
    return false;

  bool moved = false;
  if (!known_outside && IsInSector(state))
    moved = CheckTargetInside(state);
  else
    moved = CheckTargetOutside(state);

  return moved;
}
Beispiel #8
0
bool
AATPoint::CheckTarget(const AircraftState &state, const bool known_outside)
{
  if (GetActiveState() == CURRENT_ACTIVE && target_locked)
    return false;

  bool moved = false;
  if (!known_outside && IsInSector(state))
    moved = CheckTargetInside(state);
  else
    moved = CheckTargetOutside(state);

  return moved;
}
Beispiel #9
0
GeoPoint
CylinderZone::GetRandomPointInSector(const fixed mag) const
{
  GeoPoint location;

  do {
    Angle dir = Angle::Degrees(fixed(rand() % 360));
    fixed dmag = std::max(std::min(radius, fixed(100.0)), radius * mag);
    fixed dis = fixed((0.1 + (rand() % 90) / 100.0)) * dmag;
    GeoVector vec(dis, dir);
    location = vec.EndPoint(GetReference());
  } while (!IsInSector(location));

  return location;
}