本文整理汇总了C++中QVector4D::y方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector4D::y方法的具体用法?C++ QVector4D::y怎么用?C++ QVector4D::y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector4D
的用法示例。
在下文中一共展示了QVector4D::y方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
PolarVec::PolarVec(const QVector4D& _vec)
{
if (_vec.w() != 0.0)
operator=(QVector3D(_vec.x()/_vec.w(),_vec.y()/_vec.w(),_vec.z()/_vec.w()));
else
operator=(QVector3D(_vec.x(),_vec.y(),_vec.z()));
}
示例2: screenCoordinatesPerspective
void GLWidget::screenCoordinatesPerspective(QVector4D *answer, const TwoDimArray &a, double h, const QVector4D &screenCoordinates)
{
double x = screenCoordinates.x(), y = screenCoordinates.y();
double w = (a(2, 2) - a(3, 2) * h) / ((a(3, 0) * a(2, 2) - a(3, 2) * a(2, 0)) * x + (a(3, 1) * a(2, 2) - a(3, 2) * a(2, 1)) * y + a(3, 3) * a(2, 2) - a(3, 2) * a(2, 3));
*answer = QVector4D(screenCoordinates.x(), screenCoordinates.y(), (h - (a(2, 0) * x + a(2, 1) * y + a(2, 3)) * w) / a(2, 2), w);
for(int i = 0; i < 2; i++) (*answer)[i] *= w;
}
示例3: surfaceNormal
QVector4D Cylinder::surfaceNormal(const QVector4D &p, const Ray &ray)
{
QVector4D lp = m_worldToObject * p;
QMatrix4x4 a = m_worldToObject.transposed();
a.setRow(3, QVector4D(0.0, 0.0, 0.0, 1.0));
if (m_hasCaps && fabs(fabs(lp.y()) - m_length * 0.5) < MathUtils::dEpsilon) {
// Return cap normal
QVector4D n;
if (lp.y() < 0.0)
n = QVector4D(0.0, -1.0, 0.0, 0.0);
else
n = QVector4D(0.0, 1.0, 0.0, 0.0);
return (a * n).normalized();
} else {
// calculate cylinder normal
QVector4D o = QVector4D(0.0, lp.y(), 0.0, 1.0);
QVector4D n = lp - o;
n = a * n;
QVector4D rd = -ray.direction();
if (QVector4D::dotProduct(n, rd) < 0)
return -n.normalized();
else
return n.normalized();
}
}
示例4: if
QVector<float> UniformItem::getGlData() const
{
QVector<float> glData;
if (type == UniformType::SPHERICAL_3D) {
QVector4D cartesian = CoordinateConversions::sphericalToCartesian(data[0], data[1], data[2], 0.0);
glData.push_back(cartesian.x());
glData.push_back(cartesian.y());
glData.push_back(cartesian.z());
} else if (type == UniformType::SPHERICAL_4D) {
QVector4D cartesian = CoordinateConversions::sphericalToCartesian(data[0], data[1], data[2], data[3]);
glData.push_back(cartesian.x());
glData.push_back(cartesian.y());
glData.push_back(cartesian.z());
glData.push_back(cartesian.w());
} else if (type == UniformType::COLOR) {
glData.push_back(data[0] / 255.0f);
glData.push_back(data[1] / 255.0f);
glData.push_back(data[2] / 255.0f);
} else if (type == UniformType::COLOR_ALPHA) {
glData.push_back(data[0] / 255.0f);
glData.push_back(data[1] / 255.0f);
glData.push_back(data[2] / 255.0f);
glData.push_back(data[3] / 255.0f);
} else {
glData = data;
}
return glData;
}
示例5: ipEsferica
QVector4D iPolacion::ipEsferica(QVector4D q1, QVector4D q2, float lam){
// Caso facil primero.
if (lam <= 0.0f)
return q1;
else if (lam >= 1.0f)
return q2;
// Determinamos el angulo
QVector4D q2b;
float dot;
dot = q1.x() * q2.x() + q1.y() * q2.y() + q1.z() * q2.z() + q1.w() * q2.w();
if (dot >= 0.0f) {
q2b = q2;
} else {
q2b = -q2;
dot = -dot;
}
// Obtenemos los factores de interpolacion
float factor1 = 1.0f - lam;
float factor2 = lam;
if ((1.0f - dot) > 0.0000001) {
float angle = float(acos(dot));
float sinOfAngle = float(sin(angle));
if (sinOfAngle > 0.0000001) {
factor1 = float(sin((1.0f - lam) * angle)) / sinOfAngle;
factor2 = float(sin(lam * angle)) / sinOfAngle;
}
}
// Construimos el nuevo quaternion
return q1 * factor1 + q2b * factor2;
}
示例6: fuzzyCompare
static bool fuzzyCompare(const QVector4D &v1, const QVector4D &v2)
{
return qAbs(v1.x() - v2.x()) <= 0.00001 &&
qAbs(v1.y() - v2.y()) <= 0.00001 &&
qAbs(v1.z() - v2.z()) <= 0.00001 &&
qAbs(v1.w() - v2.w()) <= 0.00001;
}
示例7: screenToWorld
QVector3D Camera::screenToWorld(QVector3D vec, QMatrix4x4 modelview, QMatrix4x4 projection)
{
int viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
float winX = vec.x();
float winY = vec.y();
winY = viewport[3] - winY;
float winZ;
glReadPixels(winX, winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);
QVector4D v((winX-(float)viewport[0])/(float)viewport[2]*2.0-1.0,
(winY-(float)viewport[1])/(float)viewport[3]*2.0-1.0,
0, 1);
QVector4D v2((winX-(float)viewport[0])/(float)viewport[2]*2.0-1.0,
(winY-(float)viewport[1])/(float)viewport[3]*2.0-1.0,
1, 1);
QMatrix4x4 mat(modelview * projection);
QVector4D t = v * mat.inverted();
float w = 1 / t.w();
QVector3D pt1(t.x() * w, t.y() * w, t.z() * w);
t = v2 * mat.inverted();
w = 1 / t.w();
QVector3D pt2(t.x() * w, t.y() * w, t.z() * w);
QVector3D out;
intersects(QVector3D(1, 0, vec.z()), QVector3D(0, 1, vec.z()), QVector3D(1, 1, vec.z()),
pt1, pt2, out);
return out;
}
示例8: Property
PropertyGroup::PropertyGroup(QVector4D min, QVector4D max, QVector4D t, QString name)
{
createBox(name);
properties.emplace_back(new Property(min.x(), max.x(), t.x(), box));
properties.emplace_back(new Property(min.y(), max.y(), t.y(), box));
properties.emplace_back(new Property(min.z(), max.z(), t.z(), box));
properties.emplace_back(new Property(min.w(), max.w(), t.w(), box));
config();
}
示例9:
static inline int qsg_colorDiff(const QVector4D &a, const QVector4D &b)
{
if (a.x() != b.x())
return a.x() > b.x() ? 1 : -1;
if (a.y() != b.y())
return a.y() > b.y() ? 1 : -1;
if (a.z() != b.z())
return a.z() > b.z() ? 1 : -1;
if (a.w() != b.w())
return a.w() > b.w() ? 1 : -1;
return 0;
}
示例10: convertMouseCoordToWorld
ShipCAD::PickRay ViewportView::convertMouseCoordToWorld(QPoint pos, int w, int h) const
{
float x = (2.0f * pos.x()) / w - 1.0f;
float y = 1.0f - (2.0f * pos.y()) / h;
QVector4D from = _worldInv * QVector4D(x, y, -1.0, 1.0);
QVector4D to = _worldInv * QVector4D(x, y, 1.0, 1.0);
from /= from.w();
to /= to.w();
PickRay ray;
ray.pt = from.toVector3D();
ray.dir = to.toVector3D() - from.toVector3D();
ray.dir.normalize();
#if 0
cout << "from:" << from.x() << "," << from.y() << "," << from.z() << endl;
cout << "to:" << to.x() << "," << to.y() << "," << to.z() << endl;
// find the intersection with the xz plane if possible
Plane xz(0,1,0,0);
bool coplanar;
QVector3D intpt;
if (!xz.intersectLine(ray.pt, ray.dir, coplanar, intpt))
cout << "xz intersect:" << intpt.x() << "," << intpt.y() << "," << intpt.z() << endl;
else
cout << "parallel to xz" << endl;
if (coplanar)
cout << "coplanar" << endl;
// find the intersection with the yz plane if possible
Plane yz(1,0,0,0);
if (!yz.intersectLine(ray.pt, ray.dir, coplanar, intpt))
cout << "yz intersect:" << intpt.x() << "," << intpt.y() << "," << intpt.z() << endl;
else
cout << "parallel to yz" << endl;
if (coplanar)
cout << "coplanar" << endl;
// find the intersection with the xy plane if possible
Plane xy(0,0,1,0);
if (!xy.intersectLine(ray.pt, ray.dir, coplanar, intpt))
cout << "xy intersect:" << intpt.x() << "," << intpt.y() << "," << intpt.z() << endl;
else
cout << "parallel to xy" << endl;
if (coplanar)
cout << "coplanar" << endl;
#endif
return ray;
}
示例11: mouseMoveEvent
void GLWidget::mouseMoveEvent(QMouseEvent *event)
{
if ((event->buttons() & Qt::RightButton) && dragging) {
double xtrans = (event->pos().x() - lastPoint.x()) / 1000.0;
double ytrans = -(event->pos().y() - lastPoint.y()) / 1000.0; //Qt y-coord is inverted
QVector4D trans(xtrans, ytrans, 0, 1);
QVector4D worldTrans = trans * camera->getCameraMatrix();
if(cameraActive) {
this->camera->setpointOfInterest(scene->getMainBoat()->getPosition());
this->camera->translate(-worldTrans.x(), -worldTrans.y(), -worldTrans.z());
updateGL();
} else {
emit translate(worldTrans.x(), worldTrans.y(), worldTrans.z());
}
}
// if ((event->buttons() & Qt::LeftButton) && dragging) {
//Here we implement the trackball. Sample two points on the sphere and
//calculate their angle to use as the rotation.
//normalize to intervals [-1,1]
double lastx = clampUnit(lastPoint.x() / (this->size().width() / 2.0) - 1.0);
double lasty = clampUnit(-(lastPoint.y() / (this->size().height() / 2.0) - 1.0));
double newx = clampUnit(event->pos().x() / (this->size().width() / 2.0) - 1.0);
double newy = clampUnit(-(event->pos().y() / (this->size().height() / 2.0) - 1.0));
//Project the two points into the sphere (or the hyperbolic plane)
QVector3D v1(lastx, lasty, z(lastx, lasty));
v1.normalize();
QVector3D v2(newx, newy, z(newx, newy));
v2.normalize();
//Determine the normal of the generated plane through the center of the sphere
QVector3D normal = QVector3D::crossProduct(v1, v2);
double theta = acos(QVector3D::dotProduct(v1, v2)) / 3.0;
//angle/2.0, because the quats double cover SO(3)
QQuaternion newRot = QQuaternion(cos(theta/2.0), sin(theta/2.0) * normal.normalized());
QQuaternion cameraQuat = M4toQuat(camera->getCameraMatrix());
QQuaternion worldQuat = cameraQuat.conjugate() * newRot * cameraQuat;
if(cameraActive) {
this->camera->rotate(newRot);
updateGL();
} else {
emit rotate(&worldQuat);
}
// }
}
示例12:
QDebug operator<<(QDebug dbg, const QVector4D &vector)
{
dbg.nospace() << "QVector4D("
<< vector.x() << ", " << vector.y() << ", "
<< vector.z() << ", " << vector.w() << ')';
return dbg.space();
}
示例13: convert
void ClippingConverter::convert(const QByteArray &clippingData, const QString &directory)
{
QDataStream stream(clippingData);
stream.setFloatingPointPrecision(QDataStream::SinglePrecision);
stream.setByteOrder(QDataStream::LittleEndian);
QString newDirectory = directory;
newDirectory.replace('\\', '/');
if (!newDirectory.endsWith('/'))
newDirectory.append('/');
int objectCount, instanceCount;
stream >> objectCount >> instanceCount;
for (int i = 0; i < objectCount; ++i) {
MeshPtr mesh = importObject(stream);
// Serialize to a temporary file, then read it in again
QTemporaryFile tempFile;
if (!tempFile.open()) {
qWarning("Unable to open the temporary %s file.", qPrintable(tempFile.fileName()));
continue;
}
d->ogre->meshSerializer->exportMesh(mesh.getPointer(), tempFile.fileName().toStdString());
QByteArray meshData = tempFile.readAll();
QString meshFilename = QString("%1clipping/mesh-%2.mesh").arg(newDirectory).arg(i+1);
d->output->writeFile(meshFilename, meshData);
}
QByteArray instances;
instances.append("[");
for (int i = 0; i < instanceCount; ++i) {
QVector4D position;
int index;
stream >> position >> index;
QString line = QString("{\"position\":[%1,%2,%3],\"file\":\"%5mesh-%4.mesh\"}")
.arg(position.x())
.arg(position.y())
.arg(position.z())
.arg(index+1)
.arg(newDirectory);
if (i > 0)
instances.append(",");
instances.append(line.toAscii());
}
instances.append("]");
d->output->writeFile(newDirectory + "clipping.json", instances);
}
示例14: perspectiveTransformPoints
void HgTransformedQuad::perspectiveTransformPoints(QVector2D* outPoints, const QMatrix4x4& matrix,
const QPointF& center, const QSizeF& windowSize)
{
const QVector4D points[] =
{
QVector4D(-0.5f, -0.5f, 0.0f, 1.0f),
QVector4D( 0.5f, -0.5f, 0.0f, 1.0f),
QVector4D( 0.5f, 0.5f, 0.0f, 1.0f),
QVector4D(-0.5f, 0.5f, 0.0f, 1.0f)
};
qreal hw = windowSize.width() * 0.5f;
qreal hh = windowSize.height() * 0.5f;
for (int i = 0; i < 4; i++)
{
QVector4D temp = matrix * points[i];
outPoints[i] = QVector2D(
center.x() + temp.x() / temp.w() * hw,
center.y() + (temp.y() / temp.w() * hh) * mYDir);
}
}
示例15: vectorX
colour4::colour4( QVector4D in ) : vectorX( 4 )
{
r() = in.x();
g() = in.y();
b() = in.z();
a() = in.w();
}