Vector Class Reference

Simple two dimensional vector. More...

#include <vector.hpp>

List of all members.

Public Member Functions

 Vector (float nx, float ny)
 Vector (const Vector &other)
 Vector ()
bool operator== (const Vector &other) const
bool operator!= (const Vector &other) const
const Vectoroperator= (const Vector &other)
Vector operator+ (const Vector &other) const
Vector operator- (const Vector &other) const
Vector operator * (float s) const
Vector operator/ (float s) const
Vector operator- () const
const Vectoroperator+= (const Vector &other)
const Vectoroperator-= (const Vector &other)
const Vectoroperator *= (float val)
const Vectoroperator/= (float val)
float operator * (const Vector &other) const
 Scalar product of 2 vectors.
float norm () const
Vector unit () const

Public Attributes

float x
float y


Detailed Description

Simple two dimensional vector.

Definition at line 21 of file vector.hpp.


Constructor & Destructor Documentation

Vector::Vector ( float  nx,
float  ny 
) [inline]

Definition at line 24 of file vector.hpp.

00025     : x(nx), y(ny)
00026   { }

Vector::Vector ( const Vector other  )  [inline]

Definition at line 27 of file vector.hpp.

00028     : x(other.x), y(other.y)
00029   { }

Vector::Vector (  )  [inline]

Definition at line 30 of file vector.hpp.

Referenced by operator *(), operator+(), operator-(), and operator/().

00031     : x(0), y(0)
00032   { }


Member Function Documentation

bool Vector::operator== ( const Vector other  )  const [inline]

Definition at line 34 of file vector.hpp.

References x, and y.

00035   {
00036     return x == other.x && y == other.y;
00037   }

bool Vector::operator!= ( const Vector other  )  const [inline]

Definition at line 39 of file vector.hpp.

References x, and y.

00040   {
00041     return !(x == other.x && y == other.y);
00042   }

const Vector& Vector::operator= ( const Vector other  )  [inline]

Definition at line 44 of file vector.hpp.

References x, and y.

00045   {
00046     x = other.x;
00047     y = other.y;
00048     return *this;
00049   }

Vector Vector::operator+ ( const Vector other  )  const [inline]

Definition at line 51 of file vector.hpp.

References Vector(), x, and y.

00052   {
00053     return Vector(x + other.x, y + other.y);
00054   }

Vector Vector::operator- ( const Vector other  )  const [inline]

Definition at line 56 of file vector.hpp.

References Vector(), x, and y.

00057   {
00058     return Vector(x - other.x, y - other.y);
00059   }

Vector Vector::operator * ( float  s  )  const [inline]

Definition at line 61 of file vector.hpp.

References Vector(), x, and y.

00062   {
00063     return Vector(x * s, y * s);
00064   }

Vector Vector::operator/ ( float  s  )  const [inline]

Definition at line 66 of file vector.hpp.

References Vector(), x, and y.

00067   {
00068     return Vector(x / s, y / s);
00069   }

Vector Vector::operator- (  )  const [inline]

Definition at line 71 of file vector.hpp.

References Vector(), x, and y.

00072   {
00073     return Vector(-x, -y);
00074   }

const Vector& Vector::operator+= ( const Vector other  )  [inline]

Definition at line 76 of file vector.hpp.

References x, and y.

00077   {
00078     x += other.x;
00079     y += other.y;
00080     return *this;
00081   }

const Vector& Vector::operator-= ( const Vector other  )  [inline]

Definition at line 83 of file vector.hpp.

References x, and y.

00084   {
00085     x -= other.x;
00086     y -= other.y;
00087     return *this;
00088   }

const Vector& Vector::operator *= ( float  val  )  [inline]

Definition at line 90 of file vector.hpp.

References x, and y.

00091   {
00092     x *= val;
00093     y *= val;
00094     return *this;
00095   }

const Vector& Vector::operator/= ( float  val  )  [inline]

Definition at line 97 of file vector.hpp.

References x, and y.

00098   {
00099     x /= val;
00100     y /= val;
00101     return *this;
00102   }

float Vector::operator * ( const Vector other  )  const [inline]

Scalar product of 2 vectors.

Definition at line 105 of file vector.hpp.

References x, and y.

00106   {
00107     return x*other.x + y*other.y;
00108   }

float Vector::norm (  )  const

Definition at line 26 of file vector.cpp.

References x, and y.

Referenced by WillOWisp::active_update(), GhostTree::active_update(), Explosion::explode(), Sector::handle_collisions(), collision::makePlane(), Rock::ungrab(), unit(), worldmap::WorldMap::update(), and InfoBlock::update().

00027 {
00028   return sqrt(x*x + y*y);
00029 }

Vector Vector::unit (  )  const

Definition at line 21 of file vector.cpp.

References norm().

Referenced by WillOWisp::active_update(), GhostTree::active_update(), Explosion::explode(), and Sector::handle_collisions().

00022 {
00023   return *this / norm();
00024 }


Member Data Documentation

float Vector::x

Definition at line 115 of file vector.hpp.

Referenced by Dispenser::activate(), Totem::active_update(), Stalactite::active_update(), SSpiky::active_update(), SpiderMite::active_update(), Plant::active_update(), Owl::active_update(), Jumpy::active_update(), Haywire::active_update(), FlyingSnowBall::active_update(), Flame::active_update(), Dispenser::active_update(), Crystallo::active_update(), AngryStone::active_update(), ButtonGroup::add_button(), ButtonGroup::add_pair_of_buttons(), Player::add_velocity(), AmbientSound::AmbientSound(), Background::Background(), BonusBlock::BonusBlock(), Igel::can_see(), TileMap::change_at(), check_collisions(), Tile::check_movement_unisolid(), worldmap::WorldMap::clamp_camera_position(), Climbable::Climbable(), ParticleSystem_Interactive::collision(), AngryStone::collision_solid(), Snowman::collision_squished(), Snail::collision_squished(), MrTree::collision_squished(), MrIceBlock::collision_squished(), Sector::collision_static_constrains(), Sector::collision_tile_attributes(), Rectf::contains(), ObjectFactory::create(), Door::Door(), Font::draw(), InfoBoxLine::draw(), TileMap::draw(), SkullTile::draw(), Player::draw(), ParticleSystem::draw(), InfoBlock::draw(), Background::draw(), Menu::draw(), ButtonGroup::draw(), Button::draw(), DrawingContext::draw_center_text(), Font::draw_chars(), SDLRenderer::draw_filled_rect(), SDLLightmap::draw_filled_rect(), GLRenderer::draw_filled_rect(), GLLightmap::draw_filled_rect(), Background::draw_image(), GLRenderer::draw_inverse_ellipse(), Menu::draw_item(), SDLRenderer::draw_surface(), SDLLightmap::draw_surface(), GLRenderer::draw_surface(), GLLightmap::draw_surface(), DrawingContext::draw_surface(), SDLRenderer::draw_surface_part(), SDLLightmap::draw_surface_part(), GLRenderer::draw_surface_part(), GLLightmap::draw_surface_part(), DrawingContext::draw_surface_part(), Yeti::drop_stalactite(), Climbable::event(), Menu::event(), ButtonGroup::event(), Button::event(), DartTrap::fire(), Sector::fix_old_tiles(), Flame::Flame(), FloatingText::FloatingText(), IceCrusher::found_victim(), Ispy::free_line_of_sight(), get_anchor_pos(), worldmap::WorldMap::get_camera_pos_for_tux(), get_hit_normal(), Rectf::get_left(), SDLLightmap::get_light(), GLLightmap::get_light(), DrawingContext::get_light(), Rectf::get_middle(), TileMap::get_movement(), worldmap::WorldMap::get_next_tile(), worldmap::Tux::get_pos(), TextObject::get_pos_x(), ScriptedObject::get_pos_x(), AmbientSound::get_pos_x(), Rectf::get_right(), TileMap::get_tile_id_at(), Rectf::get_width(), SkyDive::grab(), Sector::handle_collisions(), Player::handle_input(), InfoBlock::InfoBlock(), collision::intersects(), Ispy::intersects_line(), Owl::is_above_player(), BadGuy::is_offscreen(), Camera::keep_in_bounds(), Kugelblitz::Kugelblitz(), Dispenser::launch_badguy(), worldmap::LevelTile::LevelTile(), Ispy::line_intersects_line(), worldmap::WorldMap::load_state(), TitleScreen::make_tux_jump(), collision::makePlane(), Climbable::may_climb(), Menu::Menu(), CaptainSnowball::might_climb(), BadGuy::might_fall(), MovingSprite::MovingSprite(), norm(), operator *(), operator *=(), operator!=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator<<(), operator=(), operator==(), Sector::parse_old_format(), Particles::Particles(), worldmap::WorldMap::path_ok(), SoundManager::play(), Player::position_grabbed_object(), Path::read(), collision::rectangle_aatriangle(), Rectf::Rectf(), Camera::reset(), EndSequenceWalkRight::running(), EndSequenceWalkLeft::running(), worldmap::WorldMap::save_state(), ScriptTrigger::ScriptTrigger(), SecretAreaTrigger::SecretAreaTrigger(), SequenceTrigger::SequenceTrigger(), Player::set_bonus(), SoundManager::set_listener_position(), SoundManager::set_listener_velocity(), AmbientSound::set_pos(), Menu::set_pos(), OpenALSoundSource::set_position(), collision::set_rectangle_rectangle_constraints(), Camera::set_scrolling(), Toad::set_state(), Physic::set_velocity(), OpenALSoundSource::set_velocity(), Rectf::set_width(), Camera::shake(), Zeekling::should_we_dive(), ShrinkFade::ShrinkFade(), worldmap::SpawnPoint::SpawnPoint(), SpawnPoint::SpawnPoint(), worldmap::SpecialTile::SpecialTile(), Spotlight::Spotlight(), WeakBlock::spreadHit(), worldmap::SpriteChange::SpriteChange(), Block::start_bounce(), Switch::Switch(), worldmap::Teleporter::Teleporter(), Mole::throw_rock(), worldmap::WorldMap::tile_data_at(), Kugelblitz::try_activate(), BadGuy::try_activate(), BonusBlock::try_open(), worldmap::WorldMap::update(), Wind::update(), SpriteParticle::update(), ScriptedObject::update(), RainParticleSystem::update(), Player::update(), Particles::update(), MagicBlock::update(), CometParticleSystem::update(), Bullet::update(), AmbientSound::update(), Camera::update_scroll_normal(), and Wind::Wind().

float Vector::y

Definition at line 115 of file vector.hpp.

Referenced by Sector::activate(), Zeekling::active_update(), Totem::active_update(), Stalactite::active_update(), SSpiky::active_update(), Plant::active_update(), Owl::active_update(), Jumpy::active_update(), FlyingSnowBall::active_update(), Flame::active_update(), AngryStone::active_update(), ButtonGroup::add_button(), ButtonGroup::add_pair_of_buttons(), Player::add_velocity(), AmbientSound::AmbientSound(), Background::Background(), BonusBlock::BonusBlock(), Igel::can_see(), TileMap::change_at(), check_collisions(), Tile::check_movement_unisolid(), worldmap::WorldMap::clamp_camera_position(), Climbable::Climbable(), InvisibleBlock::collides(), PneumaticPlatform::collision(), ParticleSystem_Interactive::collision(), BicyclePlatform::collision(), Dispenser::collision(), BadGuy::collision(), Kugelblitz::collision_player(), WalkingBadguy::collision_solid(), AngryStone::collision_solid(), Snowman::collision_squished(), MrTree::collision_squished(), Sector::collision_static_constrains(), Fish::collision_tile(), Sector::collision_tile_attributes(), Rectf::contains(), ObjectFactory::create(), Door::Door(), Font::draw(), InfoBoxLine::draw(), TileMap::draw(), Player::draw(), ParticleSystem::draw(), Background::draw(), Menu::draw(), ButtonGroup::draw(), Button::draw(), DrawingContext::draw_center_text(), Font::draw_chars(), SDLRenderer::draw_filled_rect(), SDLLightmap::draw_filled_rect(), GLRenderer::draw_filled_rect(), GLLightmap::draw_filled_rect(), Background::draw_image(), GLRenderer::draw_inverse_ellipse(), Menu::draw_item(), SDLRenderer::draw_surface(), SDLLightmap::draw_surface(), GLRenderer::draw_surface(), GLLightmap::draw_surface(), DrawingContext::draw_surface(), SDLRenderer::draw_surface_part(), SDLLightmap::draw_surface_part(), GLRenderer::draw_surface_part(), GLLightmap::draw_surface_part(), DrawingContext::draw_surface_part(), Climbable::event(), Menu::event(), ButtonGroup::event(), Button::event(), DartTrap::fire(), Flame::Flame(), IceCrusher::found_victim(), Ispy::free_line_of_sight(), get_anchor_pos(), Rectf::get_bottom(), worldmap::WorldMap::get_camera_pos_for_tux(), Rectf::get_height(), get_hit_normal(), SDLLightmap::get_light(), GLLightmap::get_light(), DrawingContext::get_light(), Rectf::get_middle(), TileMap::get_movement(), worldmap::WorldMap::get_next_tile(), worldmap::Tux::get_pos(), TextObject::get_pos_y(), ScriptedObject::get_pos_y(), AmbientSound::get_pos_y(), TileMap::get_tile_id_at(), Rectf::get_top(), Sector::handle_collisions(), Player::handle_input(), InfoBlock::InfoBlock(), Sector::inside(), collision::intersects(), Ispy::intersects_line(), Owl::is_above_player(), BadGuy::is_offscreen(), Camera::keep_in_bounds(), worldmap::LevelTile::LevelTile(), Ispy::line_intersects_line(), worldmap::WorldMap::load_state(), collision::makePlane(), Climbable::may_climb(), Menu::Menu(), CaptainSnowball::might_climb(), BadGuy::might_fall(), Player::move(), MovingSprite::MovingSprite(), norm(), operator *(), operator *=(), operator!=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator<<(), operator=(), operator==(), Sector::parse_old_format(), Particles::Particles(), worldmap::WorldMap::path_ok(), SoundManager::play(), PneumaticPlatform::PneumaticPlatform(), Player::position_grabbed_object(), Path::read(), collision::rectangle_aatriangle(), Rectf::Rectf(), Camera::reset(), worldmap::WorldMap::save_state(), ScriptTrigger::ScriptTrigger(), SecretAreaTrigger::SecretAreaTrigger(), SequenceTrigger::SequenceTrigger(), Player::set_bonus(), Rectf::set_height(), SoundManager::set_listener_position(), SoundManager::set_listener_velocity(), AmbientSound::set_pos(), Menu::set_pos(), OpenALSoundSource::set_position(), collision::set_rectangle_rectangle_constraints(), Camera::set_scrolling(), Physic::set_velocity(), OpenALSoundSource::set_velocity(), Camera::shake(), Zeekling::should_we_dive(), ShrinkFade::ShrinkFade(), worldmap::SpawnPoint::SpawnPoint(), SpawnPoint::SpawnPoint(), worldmap::SpecialTile::SpecialTile(), Spotlight::Spotlight(), WeakBlock::spreadHit(), worldmap::SpriteChange::SpriteChange(), Block::start_bounce(), Switch::Switch(), Totem::synchronize_with(), worldmap::Teleporter::Teleporter(), Mole::throw_rock(), worldmap::WorldMap::tile_data_at(), FlipLevelTransformer::transform_badguy(), FlipLevelTransformer::transform_moving_object(), FlipLevelTransformer::transform_sector(), FlipLevelTransformer::transform_spawnpoint(), FlipLevelTransformer::transform_tilemap(), Kugelblitz::try_activate(), worldmap::WorldMap::update(), Wind::update(), SpriteParticle::update(), SmokeCloud::update(), ScriptedObject::update(), RainParticleSystem::update(), Player::update(), Particles::update(), MagicBlock::update(), InfoBlock::update(), IceCrusher::update(), FloatingText::update(), FallingCoin::update(), CometParticleSystem::update(), Bullet::update(), BouncyCoin::update(), Block::update(), AmbientSound::update(), Menu::update(), Camera::update_scroll_normal(), and Wind::Wind().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:38 2014 for SuperTux by  doxygen 1.5.1