00001
00002 #ifndef vgl_homg_operators_3d_h_
00003 #define vgl_homg_operators_3d_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <vcl_vector.h>
00022 #include <vnl/vnl_fwd.h>
00023 #include <vgl/vgl_fwd.h>
00024 #include <vgl/vgl_homg_line_3d_2_points.h>
00025
00026
00027 template <class Type>
00028 class vgl_homg_operators_3d
00029 {
00030 typedef vgl_homg_line_3d_2_points<Type> vgl_homg_line_3d;
00031
00032 public:
00033
00034 static vnl_vector_fixed<Type,4> get_vector(vgl_homg_point_3d<Type> const& p);
00035
00036 static vnl_vector_fixed<Type,4> get_vector(vgl_homg_plane_3d<Type> const& p);
00037
00038
00039 static void unitize(vgl_homg_point_3d<Type>& a);
00040
00041 static double angle_between_oriented_lines(const vgl_homg_line_3d& line1,
00042 const vgl_homg_line_3d& line2);
00043
00044
00045 static Type distance(const vgl_homg_point_3d<Type>& point1,
00046 const vgl_homg_point_3d<Type>& point2);
00047
00048 static Type distance_squared(const vgl_homg_point_3d<Type>& point1,
00049 const vgl_homg_point_3d<Type>& point2);
00050
00051
00052 static bool is_within_distance(const vgl_homg_point_3d<Type>& p1,
00053 const vgl_homg_point_3d<Type>& p2, double d)
00054 {
00055 if (d <= 0) return false;
00056 return distance_squared(p1, p2) < d*d;
00057 }
00058
00059
00060
00061
00062
00063
00064
00065 static double perp_dist_squared(const vgl_homg_point_3d<Type>& point,
00066 const vgl_homg_plane_3d<Type>& plane);
00067 static double perp_dist_squared(const vgl_homg_plane_3d<Type>& plane,
00068 const vgl_homg_point_3d<Type>& point)
00069 { return perp_dist_squared(point, plane); }
00070
00071 static vgl_homg_point_3d<Type> intersect_line_and_plane(const vgl_homg_line_3d&,
00072 const vgl_homg_plane_3d<Type>&);
00073 #if 0 // not yet implemented
00074 static vgl_homg_point_3d<Type> lines_to_point(const vgl_homg_line_3d& line1,
00075 const vgl_homg_line_3d& line2);
00076 static vgl_homg_point_3d<Type> lines_to_point(const vcl_vector<vgl_homg_line_3d>& line_list);
00077 #endif // 0
00078 static double perp_dist_squared(const vgl_homg_line_3d& line,
00079 const vgl_homg_point_3d<Type>& point);
00080 static double perp_dist_squared(const vgl_homg_point_3d<Type>& point,
00081 const vgl_homg_line_3d& line)
00082 { return perp_dist_squared(line,point); }
00083 static vgl_homg_line_3d perp_line_through_point(const vgl_homg_line_3d& line,
00084 const vgl_homg_point_3d<Type>& point);
00085 static vgl_homg_point_3d<Type> perp_projection(const vgl_homg_line_3d& line,
00086 const vgl_homg_point_3d<Type>& point);
00087 static vgl_homg_line_3d planes_to_line(const vgl_homg_plane_3d<Type>& plane1,
00088 const vgl_homg_plane_3d<Type>& plane2);
00089 static Type plane_plane_angle(const vgl_homg_plane_3d<Type>& plane1,
00090 const vgl_homg_plane_3d<Type>& plane2);
00091 #if 0 // not yet implemented
00092 static vgl_homg_line_3d planes_to_line(const vcl_vector<vgl_homg_plane_3d<Type> >& plane_list);
00093 static vgl_homg_line_3d points_to_line(const vgl_homg_point_3d<Type>& point1,
00094 const vgl_homg_point_3d<Type>& point2);
00095 static vgl_homg_line_3d points_to_line(const vcl_vector<vgl_homg_point_3d<Type> >& point_list);
00096
00097 static vgl_homg_plane_3d<Type> points_to_plane(const vgl_homg_point_3d<Type>&,
00098 const vgl_homg_point_3d<Type>&,
00099 const vgl_homg_point_3d<Type>& );
00100 static vgl_homg_plane_3d<Type> points_to_plane(const vcl_vector<vgl_homg_point_3d<Type> >& point_list);
00101 #endif // 0
00102 static vgl_homg_point_3d<Type> intersection(const vgl_homg_plane_3d<Type>&,
00103 const vgl_homg_plane_3d<Type>&,
00104 const vgl_homg_plane_3d<Type>&);
00105 static vgl_homg_point_3d<Type> intersection(const vcl_vector<vgl_homg_plane_3d<Type> >&);
00106
00107
00108 static vgl_homg_point_3d<Type> midpoint(const vgl_homg_point_3d<Type>& p1,
00109 const vgl_homg_point_3d<Type>& p2);
00110
00111
00112 static vgl_homg_point_3d<Type> planes_to_point(const vcl_vector<vgl_homg_plane_3d<Type> >& planes);
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 static double cross_ratio(const vgl_homg_point_3d<Type>& p1,
00137 const vgl_homg_point_3d<Type>& p2,
00138 const vgl_homg_point_3d<Type>& p3,
00139 const vgl_homg_point_3d<Type>& p4);
00140 static double cross_ratio(const vgl_homg_plane_3d<Type>& p1,
00141 const vgl_homg_plane_3d<Type>& p2,
00142 const vgl_homg_plane_3d<Type>& p3,
00143 const vgl_homg_plane_3d<Type>& p4);
00144
00145
00146
00147
00148 static vgl_homg_point_3d<Type> conjugate(const vgl_homg_point_3d<Type>& a,
00149 const vgl_homg_point_3d<Type>& b,
00150 const vgl_homg_point_3d<Type>& c,
00151 double cr = -1.0);
00152
00153
00154 static vnl_vector_fixed<Type,4> most_orthogonal_vector_svd(const vcl_vector<vgl_homg_plane_3d<Type> >& planes);
00155 };
00156
00157
00158 template <class Type>
00159 vgl_homg_point_3d<Type> operator*(vnl_matrix_fixed<Type,4,4> const& m,
00160 vgl_homg_point_3d<Type> const& p);
00161
00162
00163 template <class Type>
00164 vgl_homg_point_2d<Type> operator*(vnl_matrix_fixed<Type,3,4> const& m,
00165 vgl_homg_point_3d<Type> const& p);
00166
00167
00168 template <class Type>
00169 vgl_homg_plane_3d<Type> operator*(vnl_matrix_fixed<Type,4,4> const& m,
00170 vgl_homg_plane_3d<Type> const& p);
00171
00172
00173 template <class Type>
00174 vgl_homg_plane_3d<Type> operator*(vnl_matrix_fixed<Type,4,3> const& m,
00175 vgl_homg_line_2d<Type> const& l);
00176
00177 #define VGL_HOMG_OPERATORS_3D_INSTANTIATE(T) \
00178 "Please #include <vgl/algo/vgl_homg_operators_3d.txx>"
00179
00180 #endif // vgl_homg_operators_3d_h_