fLineVec.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * The University of Tokyo
8  */
9 /*
10  * fLineVec.h
11  * Create: Katsu Yamane, 03.04.11
12  */
13 
14 #ifndef __F_LINEVEC_H__
15 #define __F_LINEVEC_H__
16 
17 #include "fMatrix3.h"
18 
19 class fLineVec;
20 int intersection(const fLineVec& lv1, const fLineVec& lv2,
21  fVec3& c1, fVec3& c2, double& d, double eps=1e-8);
22 
23 class fLineVec
24 {
25 public:
27  v_org = 0;
28  v_dir = 0;
29  temp = 0;
30  }
31  fLineVec(const fLineVec& v) {
32  v_org = v.v_org;
33  v_dir = v.v_dir;
34  temp = 0;
35  }
36  fLineVec(const fVec3& v1, const fVec3& v2) {
37  v_org = v1;
38  v_dir = v2;
39  temp = 0;
40  }
41  fLineVec(double v1, double v2, double v3, double v4, double v5, double v6) {
42  v_org(0) = v1;
43  v_org(1) = v2;
44  v_org(2) = v3;
45  v_dir(0) = v4;
46  v_dir(1) = v5;
47  v_dir(2) = v6;
48  }
50  }
51 
53  v_org.set(vec.v_org);
54  v_dir.set(vec.v_dir);
55  return *this;
56  }
57  void operator = (double d) {
58  v_org = d;
59  v_dir = d;
60  }
61 
62  friend fVec3& Org(fLineVec& v) {
63  return v.v_org;
64  }
65  friend fVec3& Dir(fLineVec& v) {
66  return v.v_dir;
67  }
68  fVec3& Org() {
69  return v_org;
70  }
71  fVec3& Dir() {
72  return v_dir;
73  }
74  const fVec3& Org() const {
75  return v_org;
76  }
77  const fVec3& Dir() const {
78  return v_dir;
79  }
80 
81  void Org(fVec3& v) {
82  v_org.set(v);
83  }
84  void Dir(fVec3& v) {
85  v_dir.set(v);
86  }
87 
88  void set(const fLineVec& vec) {
89  v_org.set(vec.v_org);
90  v_dir.set(vec.v_dir);
91  }
92  void set(const fVec3& _org, const fVec3& _dir) {
93  v_org.set(_org);
94  v_dir.set(_dir);
95  }
96 
97  friend ostream& operator << (ostream& ost, fLineVec& v);
98 
99  double* pOrg() {
100  return v_org.data();
101  }
102  double* pDir() {
103  return v_dir.data();
104  }
105 
106  /*
107  * computes p = org + t*dir
108  */
109  fVec3 position(double t) const;
110  void position(double t, fVec3& p) const;
111 
112  /*
113  * compute the nearest points and distance
114  * if the lines are parallel, computes the projection of
115  * lv2.Org() onto lv1 and returns -1
116  */
117  friend int intersection(const fLineVec& lv1, const fLineVec& lv2,
118  fVec3& c1, fVec3& c2, double& d, double eps);
119 
120  /*
121  * distance from a point
122  */
123  double distance(const fVec3& point, fVec3& pos, double* k = 0);
124 
125 protected:
128  double temp;
129 };
130 
131 #endif
fLineVec(double v1, double v2, double v3, double v4, double v5, double v6)
Definition: fLineVec.h:41
double * pDir()
Definition: fLineVec.h:102
double * pOrg()
Definition: fLineVec.h:99
fVec3 v_dir
Definition: fLineVec.h:127
fLineVec(const fLineVec &v)
Definition: fLineVec.h:31
friend fVec3 & Org(fLineVec &v)
Definition: fLineVec.h:62
void set(double *v)
Set element values from array or three values.
Definition: fMatrix3.h:314
const fVec3 & Dir() const
Definition: fLineVec.h:77
void Org(fVec3 &v)
Definition: fLineVec.h:81
fVec3 & Org()
Definition: fLineVec.h:68
friend int intersection(const fLineVec &lv1, const fLineVec &lv2, fVec3 &c1, fVec3 &c2, double &d, double eps)
Definition: fLineVec.cpp:36
fLineVec()
Definition: fLineVec.h:26
fLineVec operator=(const fLineVec &vec)
Definition: fLineVec.h:52
t
fVec3 & Dir()
Definition: fLineVec.h:71
friend ostream & operator<<(ostream &ost, fLineVec &v)
Definition: fLineVec.cpp:16
3x3 matrix and 3-element vector classes.
double distance(const fVec3 &point, fVec3 &pos, double *k=0)
Definition: fLineVec.cpp:73
int intersection(const fLineVec &lv1, const fLineVec &lv2, fVec3 &c1, fVec3 &c2, double &d, double eps=1e-8)
Definition: fLineVec.cpp:36
3-element vector class.
Definition: fMatrix3.h:206
double * data()
Pointer to the first element.
Definition: fMatrix3.h:259
fVec3 v_org
Definition: fLineVec.h:126
friend fVec3 & Dir(fLineVec &v)
Definition: fLineVec.h:65
fLineVec(const fVec3 &v1, const fVec3 &v2)
Definition: fLineVec.h:36
const fVec3 & Org() const
Definition: fLineVec.h:74
void Dir(fVec3 &v)
Definition: fLineVec.h:84
#define eps
Definition: fEulerPara.cpp:17
double temp
Definition: fLineVec.h:128
fVec3 position(double t) const
Definition: fLineVec.cpp:22
~fLineVec()
Definition: fLineVec.h:49


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:03