00001 /*-----------------------------------------------------------------------* 00002 Project:Nintendo Augmented Reality Library. 00003 File:narEdgeLine.h 00004 00005 Copyright (C)2011-2012 Nintendo Co., Ltd. All rights reserved. 00006 00007 These coded instructions, statements, and computer programs contain 00008 proprietary information of Nintendo and/or its licensed developers 00009 and are protected by national and international copyright laws. They 00010 may not be disclosed to third parties or copied or duplicated in any 00011 form, in whole or in part, without the prior written consent of 00012 Nintendo. 00013 The content herein is highly confidential and should be handled 00014 accordingly. 00015 *-----------------------------------------------------------------------*/ 00016 00018 00022 #ifndef NAR_EDGE_LINE_H__ 00023 #define NAR_EDGE_LINE_H__ 00024 00025 #include "narVec2.h" 00026 00027 namespace mw { namespace nar 00028 { 00032 class EdgeLine_cl 00033 { 00034 public: 00035 EdgeLine_cl() 00036 { 00037 Init(); 00038 } 00039 00040 void Init(); 00041 00044 bool GetIntersection( Vec2F_st * p_Point, const EdgeLine_cl & r_Edge ) const; 00045 00048 void Extend( const EdgeLine_cl & r ); 00051 void ExtendStart( const EdgeLine_cl & r ); 00054 void ExtendEnd( const EdgeLine_cl & r ); 00055 00056 f32 GetA() const { return m_A; } 00057 f32 GetB() const { return m_B; } 00058 f32 GetC() const { return m_C; } 00059 00062 void SetStart( s32 x, s32 y ) 00063 { 00064 m_Start.Set( x, y ); 00065 } 00066 00069 void SetStart( const Vec2I_st & cr ) 00070 { 00071 SetStart( cr.X(), cr.Y() ); 00072 } 00073 00076 void SetEnd( s32 x, s32 y ) 00077 { 00078 m_End.Set( x, y ); 00079 } 00080 00083 void SetEnd( const Vec2I_st & cr ) 00084 { 00085 SetEnd( cr.X(), cr.Y() ); 00086 } 00087 00090 s32 GetSquareLength() const 00091 { 00092 return GetrStart().GetSquareDistance( GetrEnd() ); 00093 } 00094 00097 void AddSample( s32 x, s32 y ); 00100 void AddSample( const Vec2I_st & cr ) 00101 { 00102 AddSample( cr.X(), cr.Y() ); 00103 } 00104 00107 bool CalcEquation(); 00111 bool SolveLinearLeastSquares(); 00115 f32 GetDistance( const Vec2F_st &r ) const; 00119 f32 GetDistance( const Vec2I_st &r ) const; 00120 00123 bool CheckSameEdgeDir( const EdgeLine_cl & cr, f32 * p_Sin, s32 * p_Dot ) const; 00124 00127 bool CheckSameEdge( const EdgeLine_cl & cr, f32 * p_Sin, s32 * p_Dot ) const; 00128 00129 private: 00131 f32 m_A; 00133 f32 m_B; 00135 f32 m_C; 00136 00137 Vec2I_st m_Start; 00138 Vec2I_st m_End; 00139 s32 m_SampleNum; 00140 s32 m_SumSquareXi; 00141 s32 m_SumSquareYi; 00142 s32 m_SumXi; 00143 s32 m_SumYi; 00144 s32 m_SumXiYi; 00145 00146 const Vec2I_st & GetrStart() const { return m_Start; } 00147 const Vec2I_st & GetrEnd() const { return m_End; } 00148 void addSums( const EdgeLine_cl & cr ); 00149 }; 00150 } 00151 } 00152 #endif 00153
© 2011-2012 Nintendo. All rights reserved.
CONFIDENTIAL