本文整理汇总了C++中Point2f类的典型用法代码示例。如果您正苦于以下问题:C++ Point2f类的具体用法?C++ Point2f怎么用?C++ Point2f使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Point2f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pixelDiff
double Parameters::pixelDiff(Shot &test, CMeshO &mesh)
{
double maxdist = 0.0;
double avedist = 0.0;
int count = 0;
CMeshO::VertexIterator vi;
for(vi = pointSamples->vert.begin(); vi != pointSamples->vert.end(); ++vi )
{
vcg::Point3f c;
c.Import((*vi).P());
Point2f diff = pixelDiff(test, c);
double dd = diff.Norm();
if(dd <= 0) continue; //outside of viewpoint
if(dd > maxdist) maxdist = dd;
avedist += dd*dd;
count++;
}
//for(int i = 0; i < nsamples; i++)
//{
// double r = (double)rand() / ((double)(RAND_MAX)+(double)(1));
// double g = (double)rand() / ((double)(RAND_MAX)+(double)(1));
// r = r*16000*16000+g*16000;
// int v = ((int)r)%(mesh.vert.size());
// vcg::Point3d c;
// c.Import(mesh.vert[v].P());
// Point2d diff = pixelDiff(test, c);
// double dd = diff.Norm();
// if(dd <= 0) continue; //outside of viewpoint
// if(dd > maxdist) maxdist = dd;
// avedist += dd*dd;
// count++;
//}
if(max_norm) return maxdist;
return sqrt(avedist/count);
}
示例2: isClose
bool SplineControl::isClose(const Point2f &p)
{
float val = getValue(p.getX());
float distance = fabs((p.getY() / height) - (1.0f - val));
return distance < (1.0f * FINGER_RANGE_FACTOR);
}
示例3: delta
Eigen::Matrix4d View::calcProjectionMatrix(Point2f frameBufferSize,float margin)
{
float near=0,far=0;
Point2d frustLL,frustUR;
frustLL.x() = -imagePlaneSize * (1.0 + margin);
frustUR.x() = imagePlaneSize * (1.0 + margin);
double ratio = ((double)frameBufferSize.y() / (double)frameBufferSize.x());
frustLL.y() = -imagePlaneSize * ratio * (1.0 + margin);
frustUR.y() = imagePlaneSize * ratio * (1.0 + margin);
near = nearPlane;
far = farPlane;
// Borrowed from the "OpenGL ES 2.0 Programming" book
Eigen::Matrix4d projMat;
Point3d delta(frustUR.x()-frustLL.x(),frustUR.y()-frustLL.y(),far-near);
projMat.setIdentity();
projMat(0,0) = 2.0f * near / delta.x();
projMat(1,0) = projMat(2,0) = projMat(3,0) = 0.0f;
projMat(1,1) = 2.0f * near / delta.y();
projMat(0,1) = projMat(2,1) = projMat(3,1) = 0.0f;
projMat(0,2) = (frustUR.x()+frustLL.x()) / delta.x();
projMat(1,2) = (frustUR.y()+frustLL.y()) / delta.y();
projMat(2,2) = -(near + far ) / delta.z();
projMat(3,2) = -1.0f;
projMat(2,3) = -2.0f * near * far / delta.z();
projMat(0,3) = projMat(1,3) = projMat(3,3) = 0.0f;
return projMat;
}
示例4: sample
/// Sample the BRDF
Color3f sample(BSDFQueryRecord &bRec, const Point2f &sample) const {
if (Frame::cosTheta(bRec.wi) <= 0)
return Color3f(0.0f);
bRec.measure = ESolidAngle;
/* Warp a uniformly distributed sample on [0,1]^2
to a direction on a cosine-weighted hemisphere */
if (sample.x() < m_ks) {
float x = sample.x()/m_ks;
Vector3f n = Warp::squareToBeckmann(Point2f(x, sample.y()), m_alpha);
bRec.wo = (2.0f * bRec.wi.dot(n) * n - bRec.wi );
}
else {
float x = (sample.x() - m_ks) / (1.0f - m_ks);
bRec.wo = Warp::squareToCosineHemisphere(Point2f(x,sample.y()));
}
if(Frame::cosTheta(bRec.wo) <= 0) {
return Color3f(0.0f);
}
/* Relative index of refraction: no change */
bRec.eta = 1.0f;
float pdfVal = pdf(bRec);
return (pdfVal != 0.0f) ? Color3f(eval(bRec) * Frame::cosTheta(bRec.wo) / pdfVal) : Color3f(0.0f);
}
示例5: assert
void Body::Update(float dt)
{
//-------------------------------------------------------
// Integrate position (verlet integration)
//-------------------------------------------------------
Point2f xAccel = netForce * invMass;
pos += velocity * dt;// + 0.5f * xAccel * dt*dt;
orientation += angVelocity * dt;
assert(xAccel.Length() < 1e3);
//-------------------------------------------------------
// Integrate velocity (implicit linear velocity)
//-------------------------------------------------------
velocity += xAccel * dt;
angVelocity += netTorque * (invInertia * dt);
//-------------------------------------------------------
// clear forces
//-------------------------------------------------------
netForce = Point2f(0.0f, 0.0f);
netTorque = 0.0f;
if (shape)
shape->update();
}
示例6: Explode
void Bullet::step(float gameTime, float deltaTime)
{
Point2f delta = dest_pos - pos;
float len;
if (!bExplode)
{
len = delta.DotProduct();
if (len < 1)
{
bExplode = false;
explodePos = pos;
Explode(gameTime);
return;
}
}
else
{
bExplode = false;
Explode(gameTime);
return;
}
Point2f vel = delta.Normalize(min(sqrtf(len) / deltaTime, speed));// 可能引发爆发事件
collisionEntity.getBody().setVelocity(vel);
collisionEntity.getBody().Update(deltaTime);
}
示例7: contains
bool Rect::contains(Point2f const & p) const
{
float left = m_corner.x();
float right = left + width();
float bottom = m_corner.y();
float top = bottom + height();
return p.x() >= left && p.x() <= right && p.y() >= bottom && p.y() <= top;
}
示例8: squareToUniformDisk
Vector3f Warp::squareToCosineHemisphere(const Point2f &sample) {
//create a sample which is cosine weighted
Point2f ptOnDisk = squareToUniformDisk(sample);
//compute the Z value
return Vector3f(ptOnDisk(0), ptOnDisk(1), sqrt(1.0 - ptOnDisk.squaredNorm()));
}
示例9: Point2f
void Player::step(float gameTime, float deltaTime)
{
gameTime, deltaTime;
Point2f dir = Point2f(400, 300) - pos;
float speed = 1 * MainGameState::getSingleton().getTimeScale();
dir.Normalize(speed);
pos += dir;
}
示例10: assert
void WMTouchEventSource::touchUp(TOUCHINPUT *ti)
{
assert(ti);
if(eventCallback != NULL)
{
Point2f p = convert(ti);
eventCallback(ti->dwID, p.getX(),p.getY(), FingerEventArgs::EventType::FINGER_REMOVED);
}
}
示例11: sample
void Mesh::samplePosition(const Point2f &_sample, Point3f &p, Normal3f &n) const {
Point2f sample(_sample);
/* First, sample a triangle with respect to surface area */
size_t index = m_distr.sampleReuse(sample.x());
/* Lookup vertex positions for the chosen triangle */
int i0 = m_indices[3*index],
i1 = m_indices[3*index+1],
i2 = m_indices[3*index+2];
const Point3f
&p0 = m_vertexPositions[i0],
&p1 = m_vertexPositions[i1],
&p2 = m_vertexPositions[i2];
/* Sample a position in barycentric coordinates */
Point2f b = squareToUniformTriangle(sample);
p = p0 * (1.0f - b.x() - b.y()) + p1 * b.x() + p2 * b.y();
/* Also provide a normal (interpolated if vertex normals are provided) */
if (m_vertexNormals) {
const Normal3f
&n0 = m_vertexNormals[i0],
&n1 = m_vertexNormals[i1],
&n2 = m_vertexNormals[i2];
n = (n0 * (1.0f - b.x() - b.y()) + n1 * b.x() + n2 * b.y()).normalized();
} else {
n = (p1-p0).cross(p2-p0).normalized();
}
}
示例12: screenSizeInDisplayCoords
Point2d View::screenSizeInDisplayCoords(Point2f &frameSize)
{
Point2d screenSize(0,0);
if (frameSize.x() == 0.0 || frameSize.y() == 0.0)
return screenSize;
screenSize.x() = tan(fieldOfView/2.0) * heightAboveSurface() * 2.0;
screenSize.y() = screenSize.x() / frameSize.x() * frameSize.y();
return screenSize;
}
示例13: int
void TargetIndicator::GraphicEntity::render(float gameTime, float deltaTime)
{
int frameTime = int(gameTime * 60);
const Rectf viewerRange(-379, 379, -279, 279); // slightly smaller than windowViewRange
const Point2f &windowSize = iRenderQueue::getSingleton().getWindowSize();
const Rectf windowRange(0, windowSize.x, 0, windowSize.y);
const Rectf windowViewRange(windowRange.leftTop.x + 20, windowRange.rightBottom.x - 20, windowRange.leftTop.y + 20, windowRange.rightBottom.y - 20);
const Point2f posOffset(windowRange.rightBottom / 2);
const Point2f viewerPos = iRenderQueue::getSingleton().getViewerPos() + posOffset;
Point2f pos;
deltaTime;
for (vector<iAttacheeEntity*>::const_iterator ie = getEntity().entities.begin(); ie != getEntity().entities.end(); ++ie)
{
if (((iTargetEntity*)*ie)->getEntity().getStatus(ESI_Position, &pos))
{
Point2f dir = pos - viewerPos;
if (viewerRange & dir)
continue;
if (dir.Length() > 500)
continue;
float direction = -atan2(dir.y, dir.x);
if (fabs(dir.x) > 1e-5)
{
Point2f pos = dir * (viewerRange.rightBottom.x / fabs(dir.x)) + posOffset;
if (windowViewRange & pos)
iRenderQueue::getSingleton().render(pos, direction, frameTime, anim, GLI_UI, true);
else
{
pos = dir * (viewerRange.rightBottom.y / fabs(dir.y)) + posOffset;
//if (windowViewRange & pos)
iRenderQueue::getSingleton().render(pos, direction, frameTime, anim, GLI_UI, true);
}
}
else
{
assert(fabs(dir.y) > 1e-5);
Point2f pos = dir * (viewerRange.rightBottom.y / fabs(dir.y)) + posOffset;
if (windowViewRange & pos)
iRenderQueue::getSingleton().render(pos, direction, frameTime, anim, GLI_UI, true);
else
{
pos = dir * (viewerRange.rightBottom.x / fabs(dir.x)) + posOffset;
//if (windowViewRange & pos)
iRenderQueue::getSingleton().render(pos, direction, frameTime, anim, GLI_UI, true);
}
}
}
}
}
示例14: numPoints
void Polygon::buildQPolygon()
{
int const n = numPoints();
m_qpolygon = QPolygonF(n);
for (int i = 0; i < n; ++i)
{
Point2f p = m_points[i];
m_qpolygon[i] = QPointF(p.x(), p.y());
}
}
示例15: updateFingerPosition
void PressAndHold::updateFingerPosition(const Point2f &newPosition)
{
float dx = position.getX() - newPosition.getX();
float dy = position.getY() - newPosition.getY();
float d = sqrt((dx * dx) + (dy * dy));
if(d >= THRESHOLD)
{
markedForDelete = true;
}
}