fLineVec.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * The University of Tokyo
00008  */
00009 /*
00010  * fLineVec.h
00011  * Create: Katsu Yamane, 03.04.11
00012  */
00013 
00014 #ifndef __F_LINEVEC_H__
00015 #define __F_LINEVEC_H__
00016 
00017 #include "fMatrix3.h"
00018 
00019 class fLineVec;
00020 int intersection(const fLineVec& lv1, const fLineVec& lv2,
00021                  fVec3& c1, fVec3& c2, double& d, double eps=1e-8);
00022 
00023 class fLineVec
00024 {
00025 public:
00026         fLineVec() {
00027                 v_org = 0;
00028                 v_dir = 0;
00029                 temp = 0;
00030         }
00031         fLineVec(const fLineVec& v) {
00032                 v_org = v.v_org;
00033                 v_dir = v.v_dir;
00034                 temp = 0;
00035         }
00036         fLineVec(const fVec3& v1, const fVec3& v2) {
00037                 v_org = v1;
00038                 v_dir = v2;
00039                 temp = 0;
00040         }
00041         fLineVec(double v1, double v2, double v3, double v4, double v5, double v6) {
00042                 v_org(0) = v1;
00043                 v_org(1) = v2;
00044                 v_org(2) = v3;
00045                 v_dir(0) = v4;
00046                 v_dir(1) = v5;
00047                 v_dir(2) = v6;
00048         }
00049         ~fLineVec() {
00050         }
00051 
00052         fLineVec operator = (const fLineVec& vec) {
00053                 v_org.set(vec.v_org);
00054                 v_dir.set(vec.v_dir);
00055                 return *this;
00056         }
00057         void operator = (double d) {
00058                 v_org = d;
00059                 v_dir = d;
00060         }
00061 
00062         friend fVec3& Org(fLineVec& v) {
00063                 return v.v_org;
00064         }
00065         friend fVec3& Dir(fLineVec& v) {
00066                 return v.v_dir;
00067         }
00068         fVec3& Org() {
00069                 return v_org;
00070         }
00071         fVec3& Dir() {
00072                 return v_dir;
00073         }
00074         const fVec3& Org() const {
00075                 return v_org;
00076         }
00077         const fVec3& Dir() const {
00078                 return v_dir;
00079         }
00080         
00081         void Org(fVec3& v) {
00082                 v_org.set(v);
00083         }
00084         void Dir(fVec3& v) {
00085                 v_dir.set(v);
00086         }
00087         
00088         void set(const fLineVec& vec) {
00089                 v_org.set(vec.v_org);
00090                 v_dir.set(vec.v_dir);
00091         }
00092         void set(const fVec3& _org, const fVec3& _dir) {
00093                 v_org.set(_org);
00094                 v_dir.set(_dir);
00095         }
00096 
00097         friend ostream& operator << (ostream& ost, fLineVec& v);
00098 
00099         double* pOrg() {
00100                 return v_org.data();
00101         }
00102         double* pDir() {
00103                 return v_dir.data();
00104         }
00105 
00106         /*
00107          * computes p = org + t*dir
00108          */
00109         fVec3 position(double t) const;
00110         void position(double t, fVec3& p) const;
00111 
00112         /*
00113          * compute the nearest points and distance
00114          * if the lines are parallel, computes the projection of
00115          * lv2.Org() onto lv1 and returns -1
00116          */     
00117         friend int intersection(const fLineVec& lv1, const fLineVec& lv2,
00118                                                         fVec3& c1, fVec3& c2, double& d, double eps);
00119 
00120         /*
00121          * distance from a point
00122          */
00123         double distance(const fVec3& point, fVec3& pos, double* k = 0);
00124         
00125 protected:
00126         fVec3 v_org;
00127         fVec3 v_dir;
00128         double temp;
00129 };
00130 
00131 #endif


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:16