src/mobility/rectangle.h
author Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
Fri, 11 Jul 2008 18:39:19 +0100
changeset 3416 926ccb845111
parent 3226 8c191779d1c2
permissions -rw-r--r--
Rescan APIs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
968
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2007 INRIA
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 */
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
#ifndef RECTANGLE_H
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#define RECTANGLE_H
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
2438
e2ac9f9aeeb9 value.h -> attribute.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2422
diff changeset
    23
#include "ns3/attribute.h"
2451
8979f07befd5 value-helper.h -> attribute-helper.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2438
diff changeset
    24
#include "ns3/attribute-helper.h"
2388
073c864796ec add Value support to Rectangle
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1817
diff changeset
    25
968
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
namespace ns3 {
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
1817
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1460
diff changeset
    28
class Vector;
968
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
/**
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
 * \brief a 2d rectangle
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
 */
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
class Rectangle
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
{
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
public:
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
  enum Side {
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
    RIGHT,
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
    LEFT,
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
    TOP,
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
    BOTTOM
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
  };
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
  /**
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
   * \param _xMin x coordinates of left boundary.
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
   * \param _xMax x coordinates of right boundary.
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
   * \param _yMin y coordinates of bottom boundary.
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
   * \param _yMax y coordinates of top boundary.
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
   *
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
   * Create a rectangle.
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
   */
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
  Rectangle (double _xMin, double _xMax,
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
             double _yMin, double _yMax);
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
  /**
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
   * Create a zero-sized rectangle located at coordinates (0.0,0.0)
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
   */
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
  Rectangle ();
3226
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    56
  /**
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    57
   * \param position the position to test.
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    58
   * \returns true if the input position is located within the rectangle, 
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    59
   *          false otherwise.
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    60
   *
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    61
   * This method compares only the x and y coordinates of the input position.
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    62
   * It ignores the z coordinate.
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    63
   */
1817
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1460
diff changeset
    64
  bool IsInside (const Vector &position) const;
3226
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    65
  /**
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    66
   * \param position the position to test.
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    67
   * \returns the side of the rectangle the input position is closest to.
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    68
   *
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    69
   * This method compares only the x and y coordinates of the input position.
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    70
   * It ignores the z coordinate.
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    71
   */
1817
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1460
diff changeset
    72
  Side GetClosestSide (const Vector &position) const;
3226
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    73
  /**
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    74
   * \param current the current position
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    75
   * \param speed the current speed
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    76
   * \returns the intersection point between the rectangle and the current+speed vector.
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    77
   *
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    78
   * This method assumes that the current position is located _inside_
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    79
   * the rectangle and checks for this with an assert.
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    80
   * This method compares only the x and y coordinates of the input position
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    81
   * and speed. It ignores the z coordinate.
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    82
   */
1817
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1460
diff changeset
    83
  Vector CalculateIntersection (const Vector &current, const Vector &speed) const;
968
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
3226
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    85
  /* The x coordinate of the left bound of the rectangle */
968
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
  double xMin;
3226
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    87
  /* The x coordinate of the right bound of the rectangle */
968
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
  double xMax;
3226
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    89
  /* The y coordinate of the bottom bound of the rectangle */
968
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
  double yMin;
3226
8c191779d1c2 doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3094
diff changeset
    91
  /* The y coordinate of the top bound of the rectangle */
968
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
  double yMax;
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
};
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
2409
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2408
diff changeset
    95
std::ostream &operator << (std::ostream &os, const Rectangle &rectangle);
8744ec60e8e6 convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2408
diff changeset
    96
std::istream &operator >> (std::istream &is, Rectangle &rectangle);
2388
073c864796ec add Value support to Rectangle
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1817
diff changeset
    97
2969
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
    98
/**
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
    99
 * \class ns3::RectangleValue
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
   100
 * \brief hold objects of type ns3::Rectangle
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
   101
 */
9d05d2a95dfa improve the auto-generated doxygen output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2582
diff changeset
   102
3094
6e787ec9c8aa ATTRIBUTE_HELPER_HEADER_2 -> ATTRIBUTE_HELPER_HEADER
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3093
diff changeset
   103
ATTRIBUTE_HELPER_HEADER (Rectangle);
2388
073c864796ec add Value support to Rectangle
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1817
diff changeset
   104
968
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
} // namespace ns3
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
70d02500c9d5 mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   107
#endif /* RECTANGLE_H */