本文整理汇总了C++中FloatPoint::length方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatPoint::length方法的具体用法?C++ FloatPoint::length怎么用?C++ FloatPoint::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatPoint
的用法示例。
在下文中一共展示了FloatPoint::length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Elastantig
void Elastantig(short i , FloatPoint & ctr)
{
FloatPoint dist = pts[i]-ctr;
float d=(float)dist.length();
FloatPoint vectunite=(dist / d);
// antigravitation try not to make it n^2
for(int k=0;k<p.agnumparts;k++)
{
int j = (frames + k + i )%ptsNum;
/* if((i==0) &&(k==0))
cout << j << " ";
*/
if(i!=j)
{
FloatPoint vect=pts[i]-pts[j];
float d1=(float)vect.length();
float d2=d1;
if(d2!=0)
{
// d include the normalisation
for(int k=0; k< p.antigorder;k++)
d2=d2*d1;
d2=(10*p.ag)/d2;
if(d2>p.maxantig)
d2=p.maxantig;
vect=(vect * d2);
if(p.noagexplosion)// just to make a sphere
vect= vect - ( vectunite * (vect % vectunite));
speed[i]+= vect ;
}
else
{
pts[i][0]+=0.01;
}
}
}
float d0=p.d0min+ (((p.dancingpartk*i +frames)%ptsNum<p.dancingpart*ptsNum)?//is it dancing?
(heights[(p.dancingpartk*i)%p.numfrq]*p.velocity)
:0);
float f=-p.k*(d-d0);
vectunite = vectunite* f;
speed[i]+= vectunite ;
speed[i]= speed[i] /p.visc;
pts[i]+= speed[i];// /1000;
if(p.mode==5)
{
ctr[2]-=50;
}
}
示例2: shapeDependentStrokeContains
bool LayoutSVGEllipse::shapeDependentStrokeContains(const FloatPoint& point)
{
// The optimized check below for circles does not support non-scaling or
// discontinuous strokes.
if (m_usePathFallback
|| !hasContinuousStroke()
|| m_radii.width() != m_radii.height()) {
if (!hasPath())
createPath();
return LayoutSVGShape::shapeDependentStrokeContains(point);
}
const FloatPoint center = FloatPoint(m_center.x() - point.x(), m_center.y() - point.y());
const float halfStrokeWidth = strokeWidth() / 2;
const float r = m_radii.width();
return std::abs(center.length() - r) <= halfStrokeWidth;
}