「GIL - 座標演算 (point2)」の編集履歴(バックアップ)一覧はこちら
追加された行は緑色になります。
削除された行は赤色になります。
2次元座標の演算
** ソース
#include <iostream>
#include <string>
#include <boost/format.hpp>
#include <boost/gil/utilities.hpp>
using namespace std;
using namespace boost;
using namespace boost::gil;
string show( string expression, point2<int> p )
{
return str( format( "%s = (%3d, %3d)" ) % expression % p.x % p[1] );
}
int main()
{
point2<int> p1( 10, 100 );
point2<int> p2;
p2.x = 20;
p2.y = 200;
cout << "num_dimensions = " << p1.num_dimensions << endl;
cout << show( "p1", p1 ) << endl;
cout << show( "p2", p2 ) << endl;
cout << show( "p1 + p2", p1 + p2 ) << endl;
cout << show( "p1 - p2", p1 - p2 ) << endl;
}
** 実行結果
num_dimensions = 2
p1 = ( 10, 100)
p2 = ( 20, 200)
p1 + p2 = ( 30, 300)
p1 - p2 = (-10, -100)
2次元座標の演算
** ソース
#include <iostream>
#include <string>
#include <boost/format.hpp>
#include <boost/gil/utilities.hpp>
using namespace std;
using namespace boost;
using namespace boost::gil;
string show( string expression, point2<int> p )
{
return str( format( "%s = (%3d, %3d)" ) % expression % p.x % p[1] );
}
int main()
{
point2<int> p1( 10, 100 );
point2<int> p2;
p2.x = 20;
p2.y = 200;
cout << "num_dimensions = " << p1.num_dimensions << endl;
cout << show( "p1", p1 ) << endl;
cout << show( "p2", p2 ) << endl;
cout << show( "p1 + p2", p1 + p2 ) << endl;
cout << show( "p1 - p2", p1 - p2 ) << endl;
}
** 実行結果
num_dimensions = 2
p1 = ( 10, 100)
p2 = ( 20, 200)
p1 + p2 = ( 30, 300)
p1 - p2 = (-10, -100)