source: trunk/packages/vizservers/nanovis/vrmath/include/vrmath/vrVector2f.h @ 2798

Last change on this file since 2798 was 2798, checked in by ldelgass, 12 years ago

Add emacs mode magic line in preparation for indentation cleanup

File size: 1.5 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2#pragma once
3#include <vrmath/vrLinmath.h>
4
5#include <cstdlib>
6#include <cmath>
7
8//#define LmExport
9class LmExport vrVector2f {
10public :
11        float   x, y;
12
13public :
14        vrVector2f() : x(0.0f), y(0.0f) {}
15        vrVector2f(const vrVector2f& v) : x(v.x), y(v.y) {}
16        vrVector2f(float x1, float y1) : x(x1), y(y1) {}
17
18        void set(float x1, float y1);
19        void set(const vrVector2f& v);
20
21        float dot() const;
22        float length() const;
23        float distance(const vrVector2f& v) const;
24        float distance(float x1, float y1) const;
25        float distanceSquare(const vrVector2f& v) const;
26        float distanceSquare(float x1, float y1) const;
27};
28
29inline void vrVector2f::set(float x1, float y1)
30{
31        x = x1;
32        y = y1;
33}
34
35inline void vrVector2f::set(const vrVector2f& v)
36{
37        x = v.x;
38        y = v.y;
39}
40
41inline float vrVector2f::dot() const
42{
43        return (x * x + y * y);
44}
45
46
47inline float vrVector2f::length() const
48{
49        return sqrt(x * x + y * y);
50}
51
52
53
54inline float vrVector2f::distance(const vrVector2f& v) const
55{
56        float x1 = (v.x - x) , y1 = (v.y - y);
57        return sqrt(x1 * x1 + y1 * y1);
58}
59
60
61
62inline float vrVector2f::distance(float x1, float y1) const
63{       
64        float x2 = (x1 - x) , y2 = (y1 - y);
65        return sqrt(x2 * x2 + y2 * y2);
66}
67
68
69
70
71inline float vrVector2f::distanceSquare(const vrVector2f& v) const
72{       
73        float x1 = (v.x - x) , y1 = (v.y - y);
74        return (x1 * x1 + y1 * y1);
75}
76
77inline float vrVector2f::distanceSquare(float x1, float y1) const
78{       
79        float x2 = (x1 - x) , y2 = (y1 - y);
80        return (x2 * x2 + y2 * y2);
81}
Note: See TracBrowser for help on using the repository browser.