本文整理汇总了C++中Vector2D::scalareProduct方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2D::scalareProduct方法的具体用法?C++ Vector2D::scalareProduct怎么用?C++ Vector2D::scalareProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector2D
的用法示例。
在下文中一共展示了Vector2D::scalareProduct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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;
}