本文整理汇总了C++中Point::Range方法的典型用法代码示例。如果您正苦于以下问题:C++ Point::Range方法的具体用法?C++ Point::Range怎么用?C++ Point::Range使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point::Range方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Divis
void Tree::Divis(const Point* begin, const Point* end, const int& color)
{
double* dl = new double(begin->Range(end));
if(*dl < kleafrate*size/33.3)
{
delete dl;
return;
}
Point middle;
double* rnd = new double(RND());
if(begin->GetX() == end->GetX() || begin->GetY() == end->GetY())
{
int krnd = (*rnd <= 0.5) ? 1 : -1;
if(begin->GetX() == end->GetX())
middle.SetXY(begin->GetX() + ((begin->GetX() + krnd * *dl/2 > 0.0) ?
krnd : -krnd) * *dl/2, min(begin->GetY(), end->GetY()) + *dl/2);
if(begin->GetY() == end->GetY())
middle.SetXY(min(begin->GetX(), end->GetX()) + *dl/2,
begin->GetY() + ((begin->GetY() + krnd * *dl/2 > 0.0) ?
krnd : -krnd) * *dl/2);
}
else if(*rnd <= 0.5) middle.SetXY(begin->GetX(), end->GetY());
else middle.SetXY(end->GetX(), begin->GetY());
delete dl;
double *chance = new double(center.Range(&sun)/middle.Range(&sun));
if(sflowers != 0 && *rnd < 0.025 * *chance)
{
f = middle;
f.Draw(color);
}
else
{
l = middle;
if(*rnd < Fi / *chance / 0.8) l.Draw(color3);
else l.Draw(color4);
}
delete chance;
delete rnd;
Divis(begin, &middle, color);
Divis(&middle, end, color);
}
示例2: Stvol
void Tree::Stvol(const Point* begin, const Point* end, const int& color)
{
if(begin->Range(end) < size/6.2) // !!!
{
Divis(begin, end, color);
setcolor(color);
return;
}
Point middle(begin, end, 1-Fi);
Point* p1 = new Point(begin, begin->Range(end)/55, begin->AngleX(end)+M_PI_2);
Point* p2 = new Point(begin, begin->Range(end)/55, begin->AngleX(end)-M_PI_2);
if(middle.Range(&sun) > center.Range(&sun))
{
setcolor(color1);
setfillstyle(1, color1);
}
else
{
setcolor(color2);
setfillstyle(1, color2);
}
int* mass = new int[6];
mass[0] = p1->GetX();
mass[1] = p1->GetY();
mass[2] = p2->GetX();
mass[3] = p2->GetY();
mass[4] = end->GetX();
mass[5] = end->GetY();
fillpoly(3, mass);
delete[] mass;
delete p2;
delete p1;
Stvol(&middle, end, color);
int krnd = (RND() < 0.5) ? -1 : 1;
// ranznos vetki 1
double* temp1 = new double((begin->Range(end) < size/16) ?
0 : (1/Fi)*random(16*(int)(begin->Range(end)/size))/begin->Range(end));
middle.Position(begin, end, 1 - Fi + krnd * *temp1);
delete temp1;
// zadanie vetki 1
double angle = M_PI_2*(random(80)+10)/100 + M_PI_2;
Point away(&middle, middle.Range(end), angle);
Stvol(&middle, &away, color);
// ranznos vetki 2
double* temp2 = new double((begin->Range(end) < size/16) ?
0 : (1/Fi)*random(16*(int)(begin->Range(end)/size))/begin->Range(end));
middle.Position(begin, end, 1 - Fi - krnd * *temp2);
delete temp2;
// zadanie vetki 1
angle = M_PI_2*(random(80)+10)/100 - M_PI_2;
away.Position(&middle, middle.Range(end), -angle);
Stvol(&middle, &away, color);
}