当前位置: 首页>>代码示例>>C++>>正文


C++ QVector2D::isNull方法代码示例

本文整理汇总了C++中QVector2D::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector2D::isNull方法的具体用法?C++ QVector2D::isNull怎么用?C++ QVector2D::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QVector2D的用法示例。


在下文中一共展示了QVector2D::isNull方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: distanceToPoint

/*!
    \since 5.1

    Returns the distance that this vertex is from a line defined
    by \a point and the unit vector \a direction.

    If \a direction is a null vector, then it does not define a line.
    In that case, the distance from \a point to this vertex is returned.

    \sa distanceToPoint()
*/
float QVector2D::distanceToLine
        (const QVector2D& point, const QVector2D& direction) const
{
    if (direction.isNull())
        return (*this - point).length();
    QVector2D p = point + dotProduct(*this - point, direction) * direction;
    return (*this - p).length();
}
开发者ID:FlavioFalcao,项目名称:qt5,代码行数:19,代码来源:qvector2d.cpp

示例2: Shoot

Bullet* Cannon::Shoot(Enemy *enemy, long elapsed)
{
    if (elapsed - lastshot < shotinterval) return 0;

    int xa = this->pixmap.size().width() - this->SizeX;
    int ya = this->pixmap.size().height() - this->SizeY;
    QVector2D tcenter(center.x() - xa * 0.5, center.y() - ya * 0.5);
    QVector2D target = GetInterSect(enemy->center, enemy->next_checkpoint,
                                    Bullet::speed, Enemy::speed,
                                    tcenter, enemy->center);
    if (target.isNull())
        target = GetInterSect2((enemy->center - enemy->next_checkpoint).length(),
                           enemy->next_checkpoint, enemy->next_checkpoint2,
                           Bullet::speed, Enemy::speed,
                           tcenter, enemy->center);

    if (target.isNull() || (this->center - target).length() > this->range)
        return 0;

    lastshot = elapsed;
    Bullet*b = new Bullet(tcenter, target, elapsed, QPixmap("bullet.png"));
    b->enemy = enemy;
    return b;
}
开发者ID:hmira,项目名称:Tower-Defense---Qt,代码行数:24,代码来源:cannon.cpp

示例3: rayCircleIntersection

QVector2D NavigationMath::rayCircleIntersection(
	bool & valid
,	const QVector2D & origin
,	const QVector2D & ray
,	const float radius)
{
	if(ray.isNull())
	{
		valid = false;
		return QVector2D();
	}

	const float a = ray.lengthSquared();
	const float b = 2. * QVector2D::dotProduct(ray, origin);
    const float c = origin.lengthSquared() - static_cast<float>(radius * radius);

	const float delta = b * b - 4. * a * c;

	if (delta < 0.0) 
	{
		valid = false;
		return QVector2D();
	}

	const float s = sqrt(delta);

	// the two intersections
	const float t0 = (-b + s) / (2.0 * a);
	const float t1 = (-b - s) / (2.0 * a);

	// nearest one
	const float t = qMin<float>(t0, t1);

	valid = true;
	return t * ray + origin;
}
开发者ID:Boffmann,项目名称:3D_Grafik,代码行数:36,代码来源:navigationmath.cpp


注:本文中的QVector2D::isNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。