-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathLine2.i
83 lines (77 loc) · 2.76 KB
/
Line2.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Copyright (C) 2021 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
%module line2
%{
#include <gz/math/Line2.hh>
#include <gz/math/Helpers.hh>
#include <gz/math/Vector2.hh>
%}
%include "std_string.i"
namespace ignition
{
namespace math
{
template<typename T>
class Line2
{
%rename("%(undercase)s", %$isfunction, %$ismember, %$not %$isconstructor) "";
public: Line2(const math::Vector2<T> &_ptA, const math::Vector2<T> &_ptB);
public: Line2(double _x1, double _y1, double _x2, double _y2);
public: void Set(const math::Vector2<T> &_ptA,
const math::Vector2<T> &_ptB);
public: void Set(double _x1, double _y1, double _x2, double _y2);
public: double CrossProduct(const Line2<T> &_line) const;
public: double CrossProduct(const Vector2<T> &_pt) const;
public: bool Collinear(const math::Vector2<T> &_pt,
double _epsilon = 1e-6) const;
public: bool Parallel(const math::Line2<T> &_line,
double _epsilon = 1e-6) const;
public: bool Collinear(const math::Line2<T> &_line,
double _epsilon = 1e-6) const;
public: bool OnSegment(const math::Vector2<T> &_pt,
double _epsilon = 1e-6) const;
public: bool Within(const math::Vector2<T> &_pt,
double _epsilon = 1e-6) const;
public: bool Intersect(const Line2<T> &_line,
double _epsilon = 1e-6) const;
public: bool Intersect(const Line2<T> &_line, math::Vector2<T> &_pt,
double _epsilon = 1e-6) const;
public: T Length() const;
public: double Slope() const;
public: bool operator==(const Line2<T> &_line) const;
public: bool operator!=(const Line2<T> &_line) const;
};
%extend Line2
{
ignition::math::Vector2<T> __getitem__(unsigned int i) const
{
return (*$self)[i];
}
}
%extend Line2
{
std::string __str__() const {
std::ostringstream out;
out << *$self;
return out.str();
}
}
%template(Line2i) Line2<int>;
%template(Line2d) Line2<double>;
%template(Line2f) Line2<float>;
}
}