本文整理汇总了C++中Point2D::setX方法的典型用法代码示例。如果您正苦于以下问题:C++ Point2D::setX方法的具体用法?C++ Point2D::setX怎么用?C++ Point2D::setX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point2D
的用法示例。
在下文中一共展示了Point2D::setX方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xmlToPoint
Point2D XMLtoVecteur::xmlToPoint(TiXmlElement* p)
{
Point2D point;
double x;
if (p->QueryDoubleAttribute("x",&x) == TIXML_SUCCESS)
{
point.setX(x);
}
else
{
point.setX(0.0);
}
double y;
if (p->QueryDoubleAttribute("y",&y) == TIXML_SUCCESS)
{
point.setY(y);
}
else
{
point.setY(0.0);
}
//cout << p->GetText() << endl;
point.setNom(p->GetText());
return point;
}
示例2: testDistanceBetween
void testDistanceBetween() {
Point2D firstPoint;
firstPoint.setX(3);
firstPoint.setY(5);
Point2D secondPoint;
secondPoint.setX(4);
secondPoint.setY(1);
cout << firstPoint.distanceTo(secondPoint) << '\n';
}
示例3:
Point2D Point2D::operator - (const Point2D &other) const
{
Point2D temp;
temp.setX(this->x - other.x);
temp.setY(this->y - other.y);
return temp;
}
示例4: testTranslate
void testTranslate() {
Point2D point;
point.setX(3);
point.setY(5);
point.translate(2, 3);
point.print();
}
示例5: render
void ConfigScene::render( unsigned int ticks )
{
Point2D textSize;
vector<Point3D> vertices;
vector<Color> colors;
vector<unsigned int short> indices;
if( ticks - this->lastDrawTicks > 15 )
{
Screen::get()->clear();
for( vector<ColoredRectangle *>::iterator it = this->rectangles.begin() ; it != this->rectangles.end() ; it++ )
(*it)->prepareRendering( vertices, colors, indices );
ColoredRectangle::render( vertices, colors, indices );
unsigned int screenWidth = Screen::get()->getWidth() - this->left - this->right;
unsigned int screenHeight = Screen::get()->getHeight() - this->top - this->bottom;
// Top
textSize.moveTo( 0, 0 );
Font::get("bitmap")->getTextSize( textSize, this->sTop );
Font::get("bitmap")->write( Point2D( this->left + (screenWidth - textSize.getX()) / 2.0f, this->top + 20 ), this->sTop );
// Left
textSize.moveTo( 0, 0 );
Font::get("bitmap")->getTextSize( textSize, this->sLeft );
Font::get("bitmap")->write( Point2D( this->left + 20, this->top + (screenHeight - textSize.getY()) / 2.0f ), this->sLeft );
// Right
textSize.moveTo( 0, 0 );
Font::get("bitmap")->getTextSize( textSize, this->sRight );
Font::get("bitmap")->write( Point2D( this->left + screenWidth - textSize.getX() - 20, this->top + (screenHeight - textSize.getY()) / 2.0f ), this->sRight );
// Bottom
textSize.moveTo( 0, 0 );
Font::get("bitmap")->getTextSize( textSize, this->sBottom );
Font::get("bitmap")->write( Point2D( this->left + (screenWidth - textSize.getX()) / 2.0f, this->top + screenHeight - textSize.getY() - 20 ), this->sBottom );
// Instructions
textSize.moveTo( 0, this->top + (screenHeight - Font::get("bitmap")->getTextHeight( this->instructions ) ) / 2.0f );
string line;
unsigned int index = 0;
size_t newLineIndex = this->instructions.find( '\n', index );
while( newLineIndex != string::npos )
{
line = this->instructions.substr( index, newLineIndex - index );
textSize.setX( this->left + (screenWidth - Font::get("bitmap")->getTextWidth( line )) / 2.0f );
Font::get("bitmap")->write( textSize, line );
textSize.moveBy( 0, Font::get("bitmap")->getTextHeight( line ) );
index = newLineIndex + 1;
newLineIndex = this->instructions.find( '\n', index );
}
if( index < this->instructions.length() )
{
line = this->instructions.substr( index );
textSize.setX( this->left + (screenWidth - Font::get("bitmap")->getTextWidth( line )) / 2.0f );
Font::get("bitmap")->write( textSize, line );
}
Font::get("bitmap")->render();
Screen::get()->render();
this->lastDrawTicks = ticks;
}
}
示例6: checkBoxes
bool Monster::checkBoxes(std::vector<CollisionBox>* boxes, float p_x, float p_y){
CollisionBox box;
Point2D A = Point2D(this->getX(), this->getY());
Point2D B;
for (int i = 0; i < boxes->size(); i++){
box = boxes->at(i);
if (box.getRight() < this->getBox().getLeft())
B.setX(box.getRight());
else if (box.getLeft() > this->getBox().getRight())
B.setX(box.getLeft());
else
B.setX(this->getX());
if (box.getTop() < this->getBox().getBottom())
B.setY(box.getTop());
else if (box.getBottom() > this->getBox().getTop())
B.setY(box.getBottom());
else
B.setY(this->getY());
float difx = (B.getX() - A.getX()) * (B.getX() - A.getX());
float dify = (B.getY() - A.getY()) * (B.getY() - A.getY());
float dist = difx + dify;
if (dist <= this->getRadius() * this->getRadius()){
if ((this->getBox().getBottom() > box.getTop() ||
this->getBox().getTop() < box.getBottom())
){
if (this->getBox().getBottom() > box.getTop()){
if (p_x == this->getX()){
this->angle = 0;
}
else if (p_x > this->getX()){
if (this->getY() < p_y)
this->angle = 8;
else
this->angle = 0;
}
else {
if (this->getY() < p_y)
this->angle = 172;
else
this->angle = 180;
}
}
else if (this->getBox().getTop() < box.getBottom()){
if (p_x == this->getX()){
this->angle = 0;
}
else if (p_x > this->getX()){
if (this->getY() > p_y)
this->angle = 352;
else
this->angle = 0;
}
else{
if (this->getY() > p_y)
this->angle = 188;
else
this->angle = 180;
}
}
}
else if ((this->getBox().getRight() < box.getLeft() || this->getBox().getLeft() > box.getRight())
){
float up = box.getTop() - this->getY();
float down = this->getY() - box.getBottom();
if (this->getBox().getRight() < box.getLeft()){
if (p_y == this->getY()){
this->angle = 90;
}
else if (p_y > this->getY()){
if (this->getX() > p_x)
this->turn(this->getX() - 16, box.getTop() + 32);
else
this->turn(this->getX(), box.getTop() + 32);
}
else{
if (this->getX() > p_x)
this->turn(this->getX() - 16, box.getBottom() - 32);
else
this->turn(this->getX(), box.getBottom() - 32);
}
//.........这里部分代码省略.........
示例7:
//Computes the Fresnel integrals S(x) and C(x) for all real x
Point2D<double> EulerSpiral::get_fresnel_integral(double x)
{
bool odd;
int k,n;
double a,ax,fact,pix2,sign,sum,sumc,sums,term,test;
std::complex<double> b,cc,d,h,del,cs;
Point2D<double> result;
ax=fabs(x);
if (ax < sqrt(FPMIN))
{
//Special case: avoid failure of convergence test because of undeflow.
result.setY(0.0);
result.setX(ax);
}
else {
if (ax <= XMIN)
{
// Evaluate both series simultaneously.
sum=sums=0.0;
sumc=ax;
sign=1.0;
fact=(M_PI/2.0)*ax*ax;
odd=true;
term=ax;
n=3;
for (k=1; k<=MAXIT; k++)
{
term *= fact/k;
sum += sign*term/n;
test=fabs(sum)*EPS;
if (odd)
{
sign = -sign;
sums=sum;
sum=sumc;
}
else {
sumc=sum;
sum=sums;
}
if (term < test) break;
odd=!odd;
n +=2;
}
if (k > MAXIT)
std::cout << "series failed in fresnel" << std::endl;
result.setY(sums);
result.setX(sumc);
}
else {
// Evaluate continued fraction by modified Lentz's method
pix2=M_PI*ax*ax;
b = std::complex<double>(1.0,-pix2);
cc = std::complex<double>(1.0/FPMIN,0.0);
d=h = std::complex<double>(1.0,0.0)/b;
n = -1;
for (k=2; k<=MAXIT; k++)
{
n +=2;
a = -n*(n+1);
b= b+std::complex<double>(4.0,0.0);
d=(std::complex<double>(1.0,0.0)/((a*d)+b));
//Denominators cannot be zero
cc=(b+(std::complex<double>(a,0.0)/cc));
del=(cc*d);
h=h*del;
if ((fabs(del.real()-1.0)+fabs(del.imag())) < EPS)
break;
}
if (k > MAXIT)
std::cout << "cf failed in frenel" << std::endl;
h=std::complex<double>(ax,-ax)*h;
cs=std::complex<double>(0.5,0.5)*(std::complex<double>(1.0,0.0) - std::complex<double>(cos(0.5*pix2),sin(0.5*pix2))*h );
result.setX(cs.real());
result.setY(cs.imag());
}
}
if (x<0) { //use antisymmetry
result = -1*result;
}
return result;
}
示例8: stepFindExactEyes
bool StudentLocalization::stepFindExactEyes(const IntensityImage &image, FeatureMap &features) const {
int temp = 0;
ImageIO::saveIntensityImage(image, ImageIO::getDebugFileName("input.png"));
IntensityImageStudent copy(image);
double** d_kern = new double*[3];
for (int y = 0; y < 3; y++) {
d_kern[y] = new double[3];
}
d_kern[0][0] = 0;
d_kern[0][1] = 1;
d_kern[0][2] = 0;
d_kern[1][0] = 1;
d_kern[1][1] = 0;
d_kern[1][2] = 1;
d_kern[2][0] = 0;
d_kern[2][1] = 1;
d_kern[2][2] = 0;
StudentKernel dilation = StudentKernel(d_kern, 3, 3, 0);
Feature top = features.getFeature(Feature::FEATURE_HEAD_TOP);
Feature bottom = features.getFeature(Feature::FEATURE_CHIN);
Feature nose_bottom = features.getFeature(Feature::FEATURE_NOSE_BOTTOM);
Feature headsideleft = features.getFeature(Feature::FEATURE_HEAD_LEFT_SIDE);
Feature headsideright = features.getFeature(Feature::FEATURE_HEAD_RIGHT_SIDE);
const int nose_to_top = nose_bottom.getY() - top.getY();
#if UNNECESSARY_CODE
#endif
Point2D<double> headsidelp = headsideleft.getPoints()[0];
headsidelp.setY(top.getY() + (nose_to_top*3/5));
headsidelp.setX((headsidelp.getX()));
Point2D<double> headsiderp = headsideright.getPoints()[0];
headsiderp.setY(nose_bottom.getY() - (nose_to_top*1/5));
headsiderp.setX((headsiderp.getX() + 3));
IntensityImageStudent eyes = ImageUtils::subimage(&image, headsidelp, headsiderp);
IntensityImageStudent eyes_dilated = dilation.dilate(&eyes);
StudentHistogram histo{eyes_dilated.getWidth()};
int zero_points[2] = { 0, histo.get_length() * 1 / 7 };
int lowest_found[2] = { eyes_dilated.getHeight(), eyes_dilated.getHeight() };
int left_out = 0, left_out_x = 0,
right_out = 0, right_out_x = 0,
left_in = 0, left_in_x = 0,
right_in = 0, right_in_x = 0;
for (int x = 0; x < histo.get_length(); x++){
temp = 0;
for (int y = 0; y < eyes_dilated.getHeight(); y++){
temp += eyes_dilated.getPixel(x, y) > 127 ? 0 : 1;
}
histo.set_value(x, temp);
if (x < histo.get_length() * 3 / 10 && temp <= lowest_found[0]){
lowest_found[0] = temp;
zero_points[0] = x;
}
if (x > histo.get_length() * 7 / 10 && temp < lowest_found[1]){
lowest_found[1] = temp;
zero_points[1] = x;
}
}
headsidelp.setX(headsidelp.getX() + zero_points[0]);
headsiderp.setX(headsiderp.getX() - (histo.get_length() - zero_points[1]));
headsidelp.setY(top.getY() + (nose_to_top * 2/ 5));
headsiderp.setY(nose_bottom.getY());
IntensityImageStudent eyes2(ImageUtils::subimage(&image, headsidelp, headsiderp));
IntensityImageStudent eyes_copy2(dilation.dilate(&eyes2));
histo.cut_to_size(zero_points[0], zero_points[1]);
for (int x = 0; x < histo.get_length(); x++){
if (x < histo.get_length() * 2 / 9){
left_out_x = histo.get_value(x) > left_out ? x : left_out_x;
left_out = histo.get_value(x) > left_out ? histo.get_value(x) : left_out;
}
else if (x < histo.get_length() * 4 / 9 && x > histo.get_length() * 2 / 9){
left_in_x = histo.get_value(x) > left_in ? x : left_in_x;
left_in = histo.get_value(x) > left_in ? histo.get_value(x) : left_in;
}
else if (x > histo.get_length() * 7 / 9){
right_out_x = histo.get_value(x) > right_out ? x : right_out_x;
right_out = histo.get_value(x) > right_out ? histo.get_value(x) : right_out;
}
else if (x > histo.get_length() * 5 / 9){
right_in_x = histo.get_value(x) > right_in ? x : right_in_x;
right_in = histo.get_value(x) > right_in ? histo.get_value(x) : right_in;
}
}
//.........这里部分代码省略.........
示例9: main
//.........这里部分代码省略.........
window.DrawLineInSpace(p55, p56);
window.DrawLineInSpace(p56, p57);
window.DrawLineInSpace(p57, p54);
window.DrawLineInSpace(p50, p54);
window.DrawLineInSpace(p51, p55);
window.DrawLineInSpace(p52, p56);
window.DrawLineInSpace(p53, p57);
window.DrawLineInSpace(p60, p61);
window.DrawLineInSpace(p61, p62);
window.DrawLineInSpace(p62, p63);
window.DrawLineInSpace(p63, p60);
window.DrawLineInSpace(p64, p65);
window.DrawLineInSpace(p65, p66);
window.DrawLineInSpace(p66, p67);
window.DrawLineInSpace(p67, p64);
window.DrawLineInSpace(p60, p64);
window.DrawLineInSpace(p61, p65);
window.DrawLineInSpace(p62, p66);
window.DrawLineInSpace(p63, p67);
//window.DrawLineInSpace(p40, p41);
window.DrawLineInSpace(p41, p42);
window.DrawLineInSpace(p42, p43);
//window.DrawLineInSpace(p43, p40);
//window.DrawLineInSpace(p44, p45);
window.DrawLineInSpace(p45, p46);
//window.DrawLineInSpace(p46, p47);
//window.DrawLineInSpace(p47, p44);
window.DrawLineInSpace(p40, p45);
window.DrawLineInSpace(p41, p45);
window.DrawLineInSpace(p42, p46);
window.DrawLineInSpace(p43, p47);
window.DrawLineInSpace(p40, p47);
window.DrawLineInSpace(p41, p49);
window.DrawLineInSpace(p42, p49);
window.DrawLineInSpace(p41, p48);
window.DrawLineInSpace(p45, p48);
if(GetAsyncKeyState(VK_DOWN)) // the DOWN arrow was pressed, let's do something
{
delta = -.1;
viewPos.setY(viewPos.getY() + cos(-viewDir.getAngle())*delta);
viewPos.setX(viewPos.getX() + sin(-viewDir.getAngle())*delta);
window.SetViewPosition(viewPos);
cout << "view pos: " << viewPos.toString() << endl;
window.DisplayNow();
Sleep(50);
}
if(GetAsyncKeyState(VK_UP)) // the UP arrow was pressed, let's do something
{
delta = .1;
viewPos.setY(viewPos.getY() + cos(-viewDir.getAngle())*delta);
viewPos.setX(viewPos.getX() + sin(-viewDir.getAngle())*delta);
window.SetViewPosition(viewPos);
cout << "view pos: " << viewPos.toString() << endl;
window.DisplayNow();
Sleep(50);
}
if(GetAsyncKeyState(VK_RIGHT)) // the RIGHT arrow was pressed, let's do something
{
delta = .1;
viewDir.setAngle(viewDir.getAngle()+delta);
window.SetViewDirection(viewDir);
cout << "view dir: " << viewDir.getAngle() << endl;
window.DisplayNow();
Sleep(50);
}
if(GetAsyncKeyState(VK_LEFT)) // the LEFT arrow was pressed, let's do something
{
delta = -.1;
viewDir.setAngle(viewDir.getAngle()+delta);
window.SetViewDirection(viewDir);
cout << "view dir: " << viewDir.getAngle() << endl;
window.DisplayNow();
Sleep(50);
}
if(GetAsyncKeyState(VK_ESCAPE))
{
return 1;
}
}
}