Line data Source code
1 : #include "Vector2f.h"
2 :
3 77 : Vector2f::Vector2f() {
4 :
5 : // For constructions without parameter.
6 77 : set(0.0, 0.0);
7 77 : }
8 :
9 1246 : Vector2f::Vector2f(float x, float y) {
10 :
11 1246 : set(x, y);
12 1246 : }
13 :
14 2081 : Vector2f::~Vector2f() {
15 2081 : }
16 :
17 1328 : void Vector2f::set(float x, float y) {
18 :
19 1328 : x_ = x;
20 1328 : y_ = y;
21 1328 : }
22 :
23 638 : Vector2f Vector2f::operator-(const Vector2f& v) const {
24 638 : return Vector2f(x_ - v.x_, y_ - v.y_);
25 : }
26 :
27 196 : Vector2f Vector2f::operator+(const Vector2f& v) const {
28 196 : return Vector2f(x_ + v.x_, y_ + v.y_);
29 : }
30 :
31 196 : Vector2f Vector2f::operator*(float a) const {
32 196 : return Vector2f(x_ * a, y_ * a);
33 : }
34 :
35 180 : float Vector2f::operator*(const Vector2f& v) const {
36 180 : return (x_ * v.x_ + y_ * v.y_);
37 : }
38 :
39 180 : Vector2f Vector2f::normal() {
40 :
41 180 : return Vector2f(y_, -x_);
42 : }
|