本文整理汇总了C++中Vector2D::getNorm方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2D::getNorm方法的具体用法?C++ Vector2D::getNorm怎么用?C++ Vector2D::getNorm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector2D
的用法示例。
在下文中一共展示了Vector2D::getNorm方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shrink
void Quadrangle::shrink(const float &l)
{
Vector2D tab[4];
for(int i=0; i<4; i++){
Vector2D orth1 = Orthogonal(-((*this)[(i+1)%4]-(*this)[i])).normalise();
Vector2D orth2 = Orthogonal( ((*this)[(i-1)%4]-(*this)[i])).normalise();
std::cout << (*this)[i] << " :: " << (*this)[(i+1)%4] << std::endl;
std::cout << (*this)[(i+1)%4]-(*this)[i] << std::endl;
std::cout << "orth1 : " << orth1 << std::endl;
std::cout << (*this)[i] << " :: " << (*this)[(i-1)%4] << std::endl;
std::cout << ((*this)[(i-1)%4]-(*this)[i]) << std::endl;
std::cout << "orth2 : " << orth2 << std::endl;
std::cout << "tab["<<i<<"] : " << tab[i] << std::endl;
Vector2D v = (orth1 + orth2)/2;
std::cout << "v.Norm() : " << v.getNorm() << std::endl;
std::cout << std::endl;
tab[i] = (*this)[i]+Normalized(v)*(l/(v.getNorm()));
}
for(int i=0; i<4; i++){
std::cout << "tab["<<i<<"] : " << tab[i] << std::endl;
(*this)[i] = tab[i];
}
}
示例2: remplissageCoin
Mesh PaterneQuad::remplissageCoin(const int& indicePointCoin, Vector2D& point1Batiment, Vector2D& pointCentre, Vector2D& point3Batiment)
{
/*
point1 X----X point2
| |
| |
point0 X----X point3
*/
Quadrangle centreTmp = *this;
// Taille aléatoire
float aleatoire = (rand()%100) / 100.0;
centreTmp.shrink( _par->minLargeurBatiment + aleatoire*(coeffShrinkMax()-_par->minLargeurBatiment-_par->largeurRuelle) );
//
pointCentre = centreTmp[indicePointCoin];
Vector2D shrink = pointCentre - get(indicePointCoin);
Vector2D pIpIm1 = get((indicePointCoin-1)%4) - get(indicePointCoin);
Vector2D pIpIp1 = get((indicePointCoin+1)%4) - get(indicePointCoin);
pIpIm1.normalise(); pIpIp1.normalise();
// disposition des points en losange
float dpIpIm1 = shrink.scalareProduct(pIpIm1);
dpIpIm1 = shrink.getNorm()*shrink.getNorm() / (dpIpIm1*2);
if(dpIpIm1 >= (get((indicePointCoin-1)%4) - get(indicePointCoin)).getNorm()/2)
dpIpIm1 = (get((indicePointCoin-1)%4) - get(indicePointCoin)).getNorm()/2 - _par->largeurRuelle/2;
float dpIpIp1 = shrink.scalareProduct(pIpIp1);
dpIpIp1 = shrink.getNorm()*shrink.getNorm() / (dpIpIp1*2);
if(dpIpIp1 >= (get((indicePointCoin+1)%4) - get(indicePointCoin)).getNorm()/2)
dpIpIp1 = (get((indicePointCoin+1)%4) - get(indicePointCoin)).getNorm()/2 - _par->largeurRuelle/2;
point1Batiment = get(indicePointCoin) + pIpIp1*dpIpIp1;
point3Batiment = get(indicePointCoin) + pIpIm1*dpIpIm1;
Batiment b = Batiment(Vector3D(get(indicePointCoin).x, get(indicePointCoin).y, 0),
Vector3D(point1Batiment.x, point1Batiment.y, 0),
Vector3D(pointCentre.x, pointCentre.y, 0),
Vector3D(point3Batiment.x, point3Batiment.y, 0),
_par);
return b.generate();
}
示例3: areaTriangle
//préfère le mettre dans un fichier de calcul à part.
float areaTriangle(const Vector2D& p0, const Vector2D& p1, const Vector2D& p2)
{
Vector2D ab = p1-p0;
Vector2D ac = p2-p0;
float base = ab.getNorm();
float d = ab.scalareProduct(ac)/base;
float h = sqrt(ac.getNorm2()-d*d);
return h*base*0.5;
}
示例4: shrinkPoly
void Polygone::shrinkPoly(int nb, float l)
{
if(l == 0)
return;
Vector2D tab[nb];
for(int i = 0; i < nb; i++)
{
Vector2D v1 = Orthogonal(get(i)-get(i+1)).normalised();
Vector2D v2 = Orthogonal(get(i-1)-get(i)).normalised();
Vector2D v = (v1+v2)/2; //quand on augmente de 1 sur v1 ou v2, on augment de v.norm() sur le v.
tab[i] = get(i)+Normalized(v)*(l/v.getNorm());
}
for(int i = 0; i < nb; i++)
set(i, tab[i]);
}