line.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <geometry/line.h>
00025 #include <utils/math/angle.h>
00026 #include <math.h>
00027 #include <iostream>
00028
00029 namespace fawkes {
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 Line::Line(const HomPoint& p, const HomVector& v)
00049 : GeomObj(HomTransform().reset(), HomPoint(0.0, 0.0, 0.0))
00050 {
00051 mBasePoint = p;
00052 mDirection = v;
00053
00054
00055
00056
00057 float z_angle = atan( mDirection.y() / mDirection.x() );
00058
00059
00060 HomVector direction_xy = mDirection;
00061 direction_xy.z() = 0.0;
00062 float y_angle = -atan( mDirection.z() / direction_xy.length() );
00063
00064
00065 mToRefCS.rotate_z(z_angle);
00066
00067 mToRefCS.rotate_y(y_angle);
00068
00069 mToRefCS.trans(mBasePoint.x(), mBasePoint.y(), mBasePoint.z());
00070
00071 mChanged = true;
00072 }
00073
00074
00075
00076
00077
00078
00079 Line::Line(const HomPoint& p1, const HomPoint& p2)
00080 : GeomObj(HomTransform().reset(), HomPoint(0.0, 0.0, 0.0))
00081 {
00082 mBasePoint = p1;
00083 mDirection = p2 - p1;
00084
00085
00086
00087
00088 float z_angle = atan( mDirection.y() / mDirection.x() );
00089
00090
00091 HomVector direction_xy = mDirection;
00092 direction_xy.z() = 0.0;
00093 float y_angle = -atan( mDirection.z() / direction_xy.length() );
00094
00095
00096 mToRefCS.rotate_z(z_angle);
00097
00098 mToRefCS.rotate_y(y_angle);
00099
00100 mToRefCS.trans(mBasePoint.x(), mBasePoint.y(), mBasePoint.z());
00101
00102 mChanged = true;
00103 }
00104
00105
00106
00107 Line::~Line()
00108 {
00109 }
00110
00111
00112
00113
00114
00115
00116 Line&
00117 Line::apply_transform(const HomTransform& t)
00118 {
00119 _apply_transform(t);
00120
00121 return *this;
00122 }
00123
00124
00125
00126
00127
00128
00129 Line&
00130 Line::apply_transform_ref(const HomTransform& t)
00131 {
00132 _apply_transform_ref(t);
00133
00134 return *this;
00135 }
00136
00137
00138
00139
00140
00141
00142
00143
00144 Line&
00145 Line::trans(float trans_x, float trans_y, float trans_z)
00146 {
00147 _trans(trans_x, trans_y, trans_z);
00148
00149 return *this;
00150 }
00151
00152
00153
00154
00155
00156
00157
00158
00159 Line&
00160 Line::trans_ref(float trans_x, float trans_y, float trans_z)
00161 {
00162 _trans_ref(trans_x, trans_y, trans_z);
00163
00164 return *this;
00165 }
00166
00167
00168
00169
00170
00171
00172 Line&
00173 Line::rotate_x(float angle)
00174 {
00175 _rotate_x(angle);
00176
00177 return *this;
00178 }
00179
00180
00181
00182
00183
00184
00185 Line&
00186 Line::rotate_y(float angle)
00187 {
00188 _rotate_y(angle);
00189
00190 return *this;
00191 }
00192
00193
00194
00195
00196
00197
00198 Line&
00199 Line::rotate_z(float angle)
00200 {
00201 _rotate_z(angle);
00202
00203 return *this;
00204 }
00205
00206
00207
00208
00209
00210
00211 Line&
00212 Line::rotate_x_ref(float angle)
00213 {
00214 _rotate_x_ref(angle);
00215
00216 return *this;
00217 }
00218
00219
00220
00221
00222
00223
00224 Line&
00225 Line::rotate_y_ref(float angle)
00226 {
00227 _rotate_y_ref(angle);
00228
00229 return *this;
00230 }
00231
00232
00233
00234
00235
00236
00237 Line&
00238 Line::rotate_z_ref(float angle)
00239 {
00240 _rotate_z_ref(angle);
00241
00242 return *this;
00243 }
00244
00245 }