Vec3d StelMovementMgr::mountFrameToJ2000(const Vec3d& v) const { switch (mountMode) { case MountAltAzimuthal: return core->altAzToJ2000(v, StelCore::RefractionOff); case MountEquinoxEquatorial: return core->equinoxEquToJ2000(v); case MountGalactic: return core->galacticToJ2000(v); } Q_ASSERT(0); return Vec3d(0); }
SoundSource::SoundSource(double nearClip, double farClip, AttenuationLaw law, DopplerType dopplerType, double farBias, int delaySize ) : DistAtten<double>(nearClip, farClip, law, farBias), mSound(delaySize), mUseAtten(true), mDopplerType(dopplerType), mUsePerSampleProcessing(false) { // initialize the position history to be VERY FAR AWAY so that we don't deafen ourselves... for(int i=0; i<mPosHistory.size(); ++i){ mPosHistory(Vec3d(1000, 0, 0)); } presenceFilter.set(2700); }
Vec3d CameraController::switchCoordinateSystem_vector( const Vec3d& vec, const Matrixd& from, const Matrixd& to ) { Matrixd mat; mat.invert(to); Vec3d begin = Vec3d(0, 0, 0); Vec3d end = vec; Vec3d begin2 = begin * from * mat; Vec3d end2 = end * from * mat; Vec3d v = end2 - begin2; return v; }
void MassPointSystem::buildDoubleTetrahedron(const Vec3d ¢er, const Vec3d &vel, const Vec3d &angVel) { massPointVector.push_back(MassPoint(center + Vec3d(0.0, 0.0, 4.082), vel + angVel.cross(Vec3d(0.0, 0.0, 4.082)))); massPointVector.push_back(MassPoint(center + Vec3d(-1.443, -2.5, 0.0), vel + angVel.cross(Vec3d(-1.443, -2.5, 0.0)))); massPointVector.push_back(MassPoint(center + Vec3d(-1.443, 2.5, 0.0), vel + angVel.cross(Vec3d(-1.443, 2.5, 0.0)))); massPointVector.push_back(MassPoint(center + Vec3d(2.886, 0.0, 0.0), vel + angVel.cross(Vec3d(2.886, 0.0, 0.0)))); massPointVector.push_back(MassPoint(center + Vec3d(0.0, 0.0, -4.082), vel + angVel.cross(Vec3d(0.0, 0.0, -4.082)))); jointVector.push_back(new SpringDamperJoint(0, 1, &massPointVector)); jointVector.push_back(new SpringDamperJoint(0, 2, &massPointVector)); jointVector.push_back(new SpringDamperJoint(0, 3, &massPointVector)); jointVector.push_back(new SpringDamperJoint(1, 2, &massPointVector)); jointVector.push_back(new SpringDamperJoint(1, 3, &massPointVector)); jointVector.push_back(new SpringDamperJoint(1, 4, &massPointVector)); jointVector.push_back(new SpringDamperJoint(2, 3, &massPointVector)); jointVector.push_back(new SpringDamperJoint(2, 4, &massPointVector)); jointVector.push_back(new SpringDamperJoint(3, 4, &massPointVector)); for (unsigned int i = 0; i < massPointVector.size(); ++i) { jointVector.push_back(new GroundContactJoint(i)); jointVector.push_back(new GravityJoint(i)); } }
Vec3d StelMovementMgr::j2000ToMountFrame(const Vec3d& v) const { switch (mountMode) { case MountAltAzimuthal: return core->j2000ToAltAz(v, StelCore::RefractionOff); case MountEquinoxEquatorial: return core->j2000ToEquinoxEqu(v); case MountGalactic: return core->j2000ToGalactic(v); } Q_ASSERT(0); return Vec3d(0); }
Vec3d Camera::collisionPointOnPlane( const Mat4x4f &proj, const Mat4x4f &modelview, const Vec2i &resolution, const Vec2i &screen_point, Vec3f planeNormal) const { Vec3f start = screenSpacePointTo3DRay( proj, modelview, resolution, screen_point, 0.0); Vec3f end = screenSpacePointTo3DRay( proj, modelview, resolution, screen_point, 1.0); Vec3f line = start - end; float len = (-start).dot(planeNormal / line.dot(planeNormal)); Vec3f i = start + (line * len); return Vec3d(i.x, i.y, i.z); }
void MeshPointSet::BeforeStep(double deltaTime) { MaterialPointSet::BeforeStep(deltaTime); for(int i=0; i < m_count; i++) m_stiffnessForces[i] = Vec3d(0); if (m_s == 0) return; for(int ix = 1; ix < m_Nx - 1; ++ix) for(int iy = 1; iy < m_Ny - 1; ++iy) { int id = ix + m_Nx * iy; Vec3d toNeighbours = Vec3d(0); for(int dir = 0; dir < 8; dir += 1) { int nxNeighbour = ix + g_vecDir[dir].x; int nyNeighbour = iy + g_vecDir[dir].y; int neighbourID = nxNeighbour + nyNeighbour*m_Nx; if(nxNeighbour >= 0 && nxNeighbour < m_Nx && nyNeighbour >= 0 && nyNeighbour < m_Ny) { Vec3d diff = m_points[neighbourID].m_pos - m_points[id].m_pos; toNeighbours+=diff; } } toNeighbours *= (1.0/8.0); Vec3d force = m_s * toNeighbours; m_stiffnessForces[id] += force; for(int dir = 0; dir < 8; dir += 1) { int nxNeighbour = ix + g_vecDir[dir].x; int nyNeighbour = iy + g_vecDir[dir].y; int neighbourID = nxNeighbour + nyNeighbour*m_Nx; m_stiffnessForces[neighbourID] -= force*(1.0/8.0); } } }
// automatically generates edges: DLL_HEADER Ng_Result Ng_STL_MakeEdges (Ng_STL_Geometry * geom, Ng_Mesh* mesh, Ng_Meshing_Parameters * mp) { STLGeometry* stlgeometry = (STLGeometry*)geom; Mesh* me = (Mesh*)mesh; // Philippose - 27/07/2009 // Do not locally re-define "mparam" here... "mparam" is a global // object //MeshingParameters mparam; mp->Transfer_Parameters(); me -> SetGlobalH (mparam.maxh); me -> SetLocalH (stlgeometry->GetBoundingBox().PMin() - Vec3d(10, 10, 10), stlgeometry->GetBoundingBox().PMax() + Vec3d(10, 10, 10), 0.3); me -> LoadLocalMeshSize (mp->meshsize_filename); /* if (mp->meshsize_filename) { ifstream infile (mp->meshsize_filename); if (!infile.good()) return NG_FILE_NOT_FOUND; me -> LoadLocalMeshSize (infile); } */ STLMeshing (*stlgeometry, *me); stlgeometry->edgesfound = 1; stlgeometry->surfacemeshed = 0; stlgeometry->surfaceoptimized = 0; stlgeometry->volumemeshed = 0; return NG_OK; }
void StelMovementMgr::panView(const double deltaAz, const double deltaAlt) { // The function is called in update loops, so make a quick check for exit. if ((deltaAz==0.) && (deltaAlt==0.)) return; double azVision, altVision; StelUtils::rectToSphe(&azVision,&altVision,j2000ToMountFrame(viewDirectionJ2000)); // Az is counted from South, eastward. // qDebug() << "Azimuth:" << azVision * 180./M_PI << "Altitude:" << altVision * 180./M_PI << "Up.X=" << upVectorMountFrame.v[0] << "Up.Y=" << upVectorMountFrame.v[1] << "Up.Z=" << upVectorMountFrame.v[2]; // if we are just looking into the pole, azimuth can hopefully be recovered from the customized up vector! // When programmatically centering on a pole, we should have set a better up vector for |alt|>0.9*M_PI/2. if (fabs(altVision)> 0.95* M_PI/2.) { if (upVectorMountFrame.v[2] < 0.9) { // qDebug() << "Recovering azimuth..."; azVision=atan2(-upVectorMountFrame.v[1], -upVectorMountFrame.v[0]); if (altVision < 0.) azVision+=M_PI; } // else // { // // qDebug() << "UpVector:" << upVectorMountFrame.v[0] << "/" << upVectorMountFrame.v[1] << "/" << upVectorMountFrame.v[2] << "Cannot recover azimuth. Hope it's OK"; // } } // if we are moving in the Azimuthal angle (left/right) if (deltaAz) azVision-=deltaAz; if (deltaAlt) { if (altVision+deltaAlt <= M_PI_2 && altVision+deltaAlt >= -M_PI_2) altVision+=deltaAlt; if (altVision+deltaAlt > M_PI_2) altVision = M_PI_2 - 0.000001; // Prevent bug if (altVision+deltaAlt < -M_PI_2) altVision = -M_PI_2 + 0.000001; // Prevent bug } // recalc all the position variables if (deltaAz || deltaAlt) { setFlagTracking(false); Vec3d tmp; StelUtils::spheToRect(azVision, altVision, tmp); setViewDirectionJ2000(mountFrameToJ2000(tmp)); setViewUpVector(Vec3d(0., 0., 1.)); // We ensured above that view vector is never parallel to this simple up vector. } }
int Ng_STLCalcLocalH (ClientData clientData, Tcl_Interp * interp, int argc, tcl_const char *argv[]) { for (int i = 0; i < geometryregister.Size(); i++) geometryregister[i] -> SetParameters (interp); Ng_SetMeshingParameters (clientData, interp, argc, argv); STLGeometry * stlgeometry = dynamic_cast<STLGeometry*> (ng_geometry); if (mesh.Ptr() && stlgeometry) { mesh -> SetLocalH (stlgeometry->GetBoundingBox().PMin() - Vec3d(10, 10, 10), stlgeometry->GetBoundingBox().PMax() + Vec3d(10, 10, 10), mparam.grading); stlgeometry -> RestrictLocalH(*mesh, mparam.maxh); if (stlparam.resthsurfmeshcurvenable) mesh -> CalcLocalHFromSurfaceCurvature (stlparam.resthsurfmeshcurvfac); } return TCL_OK; }
// read a correspondence in history bool MyGlWindow::read_correspondence ( int frameid, int lineid, EdgePlane *ep ) { char filename[256]; sprintf(filename, "correspondences/%d.dat", frameid); FILE *f = fopen( filename, "r" ); if ( !f ) return false; double s0,s1,s2,a0,a1,a2,b0,b1,b2; int camera_id, line_status,line_id; while ( fscanf(f, "%d%d%d%lf%lf%lf%lf%lf%lf%lf%lf%lf", &line_id, &line_status, &camera_id, &s0, &s1, &s2, &a0, &a1, &a2, &b0, &b1, &b2 ) == 12 ) { if ( line_id == lineid ) { ep->_a = Vec3d(a0,a1,a2); ep->_b = Vec3d(b0,b1,b2); ep->_s = Vec3d(s0,s1,s2); ep->_cameraId = camera_id; ep->_normal = norm(cross(norm(ep->_a),norm(ep->_b))); ep->_uid = 0; ep->_length = ep->length(); fclose(f); return true; } } fclose (f); return false; }
// automatically generates edges: DLL_HEADER Ng_Result Ng_STL_MakeEdges (Ng_STL_Geometry * geom, Ng_Mesh* mesh, Ng_Meshing_Parameters * mp) { STLGeometry* stlgeometry = (STLGeometry*)geom; Mesh* me = (Mesh*)mesh; MeshingParameters mparam; mparam.maxh = mp->maxh; mparam.meshsizefilename = mp->meshsize_filename; me -> SetGlobalH (mparam.maxh); me -> SetLocalH (stlgeometry->GetBoundingBox().PMin() - Vec3d(10, 10, 10), stlgeometry->GetBoundingBox().PMax() + Vec3d(10, 10, 10), 0.3); me -> LoadLocalMeshSize (mp->meshsize_filename); /* if (mp->meshsize_filename) { ifstream infile (mp->meshsize_filename); if (!infile.good()) return NG_FILE_NOT_FOUND; me -> LoadLocalMeshSize (infile); } */ STLMeshing (*stlgeometry, *me); stlgeometry->edgesfound = 1; stlgeometry->surfacemeshed = 0; stlgeometry->surfaceoptimized = 0; stlgeometry->volumemeshed = 0; return NG_OK; }
void GLGizmoRotate::render_grabber(const BoundingBoxf3& box) const { double grabber_radius = (double)m_radius * (1.0 + (double)GrabberOffset); m_grabbers[0].center = Vec3d(::cos(m_angle) * grabber_radius, ::sin(m_angle) * grabber_radius, 0.0); m_grabbers[0].angles(2) = m_angle; glsafe(::glColor3fv((m_hover_id != -1) ? m_drag_color : m_highlight_color)); ::glBegin(GL_LINES); ::glVertex3f(0.0f, 0.0f, 0.0f); ::glVertex3dv(m_grabbers[0].center.data()); glsafe(::glEnd()); ::memcpy((void*)m_grabbers[0].color, (const void*)m_highlight_color, 3 * sizeof(float)); render_grabbers(box); }
// return the average camera position over the last n frames // Vec3d MyGlWindow::get_average_position( int n ) { Vec3d t = Vec3d(0,0,0); int counter = 0; for (int i=pose_history.size()-1;i>=MAX(0,pose_history.size()-n);i--) { t = t + pose_history[i].getTranslation(); counter++; } if ( counter > 0 ) t = t / counter; return t; }
void TestStelSphericalGeometry::testGreatCircleIntersection() { Vec3d v0,v1,v2,v3; double deg5 = 5.*M_PI/180.; StelUtils::spheToRect(-deg5, -deg5, v3); StelUtils::spheToRect(+deg5, -deg5, v2); StelUtils::spheToRect(+deg5, +deg5, v1); StelUtils::spheToRect(-deg5, +deg5, v0); bool ok; Vec3d v(0); QBENCHMARK { v = greatCircleIntersection(v3, v1, v0, v2, ok); } QVERIFY(v.angle(Vec3d(1.,0.,0.))<0.00001); }
inline Vec3d barycentric_coordinates(const Vec3d& P, const Vec3d& A, const Vec3d& B, const Vec3d& C){ Vec3d v0 = B - A, v1 = C - A, v2 = P - A; double d00 = dot(v0, v0); double d01 = dot(v0, v1); double d02 = dot(v0, v2); double d11 = dot(v1, v1); double d12 = dot(v1, v2); double w = (d00 * d12 - d01 * d02) / (d00 * d11 - d01 * d01); double v = (d00 >= d01)? (d02 - d01 * w) / d00: (d12 - d11 * w) / d01; //double v = (d00 >= d01)? d02 / d00 - (d01 / d00) * w: d12 / d01 - (d11 / d01) * w; double u = 1.0 - v - w; return Vec3d(u, v, w); }
PointerCoordinates::PointerCoordinates() : currentPlace(TopRight) , flagShowCoordinates(false) , flagEnableAtStartup(false) , flagShowCoordinatesButton(false) , textColor(Vec3f(1,0.5,0)) , coordinatesPoint(Vec3d(0,0,0)) , fontSize(14) , toolbarButton(NULL) { setObjectName("PointerCoordinates"); mainWindow = new PointerCoordinatesWindow(); StelApp &app = StelApp::getInstance(); conf = app.getSettings(); gui = dynamic_cast<StelGui*>(app.getGui()); }
Comet::Comet(const QString& englishName, int flagLighting, double radius, double oblateness, Vec3f color, float albedo, const QString& atexMapName, posFuncType coordFunc, void* auserDataPtr, OsculatingFunctType *osculatingFunc, bool acloseOrbit, bool hidden, const QString& pType) : Planet (englishName, flagLighting, radius, oblateness, color, albedo, atexMapName, coordFunc, auserDataPtr, osculatingFunc, acloseOrbit, hidden, false, //No atmosphere pType) { texMapName = atexMapName; lastOrbitJD =0; deltaJD = StelCore::JD_SECOND; orbitCached = 0; closeOrbit = acloseOrbit; eclipticPos=Vec3d(0.,0.,0.); rotLocalToParent = Mat4d::identity(); //Comet specific members absoluteMagnitude = 0; slopeParameter = -1;//== uninitialized: used in getVMagnitude() //TODO: Name processing? nameI18 = englishName; flagLabels = true; }
bool GetDe431Coor(const double jde, const int planet_id, double * xyz, const int centralBody_id) { if(initDone) { // This may return some error code! int jplresult=jpl_pleph(ephem, jde, planet_id, centralBody_id, tempXYZ, 0); switch (jplresult) { case 0: // all OK. break; case JPL_EPH_OUTSIDE_RANGE: qDebug() << "GetDe431Coor: JPL_EPH_OUTSIDE_RANGE at jde" << jde << "for planet" << planet_id; return false; break; case JPL_EPH_READ_ERROR: qDebug() << "GetDe431Coor: JPL_EPH_READ_ERROR at jde" << jde << "for planet" << planet_id; return false; break; case JPL_EPH_QUANTITY_NOT_IN_EPHEMERIS: qDebug() << "GetDe431Coor: JPL_EPH_QUANTITY_NOT_IN_EPHEMERIS at jde" << jde << "for planet" << planet_id; return false; break; case JPL_EPH_INVALID_INDEX: qDebug() << "GetDe431Coor: JPL_EPH_INVALID_INDEX at jde" << jde << "for planet" << planet_id; return false; break; case JPL_EPH_FSEEK_ERROR: qDebug() << "GetDe431Coor: JPL_EPH_FSEEK_ERROR at jde" << jde << "for planet" << planet_id; return false; break; default: // Should never happen... qDebug() << "GetDe431Coor: unknown error" << jplresult << "at jde" << jde << "for planet" << planet_id; return false; break; } tempICRF = Vec3d(tempXYZ[0], tempXYZ[1], tempXYZ[2]); tempECL = StelCore::matJ2000ToVsop87 * tempICRF; xyz[0] = tempECL[0]; xyz[1] = tempECL[1]; xyz[2] = tempECL[2]; return true; } return false; }
void Driver::shrinkVN(vector<Vec3d>& new_positions,SurfTrack* g_surf,VectorXd& VN,double t) { vector<Vec3d> normals; vector<int> count; normals.assign(new_positions.size(),Vec3d(0,0,0)); count.assign(new_positions.size(),0); vector<Vec3st> triangles=g_surf->m_mesh.get_triangles(); vector<Vec3d> vertexes=g_surf->get_positions(); int index=0; for (int i=0;i<triangles.size();i++) { if (!g_surf->triangle_is_on_surf(i)||g_surf->m_mesh.triangle_is_deleted(i)) { continue; } if (g_surf->triangle_is_locked(i)) { index++; continue; } Vec3d fN=g_surf->get_triangle_normal(i); fN*=VN[index]*t; normals[triangles[i][0]]+=fN; normals[triangles[i][1]]+=fN; normals[triangles[i][2]]+=fN; count[triangles[i][0]]++; count[triangles[i][1]]++; count[triangles[i][2]]++; index++; } for (int i=0;i<new_positions.size();i++) { if (!g_surf->vertex_is_on_surf(i)||g_surf->vertex_is_locked(i)||g_surf->m_mesh.vertex_is_deleted(i)) { new_positions[i]=vertexes[i]; continue; } if (count[i]==0){ //cout<<"test"<<endl; new_positions[i]=vertexes[i]; } else new_positions[i]=vertexes[i]+normals[i]/count[i]; } }
void DiagonalMass<Rigid2fTypes, Rigid2fMass>::draw(const core::visual::VisualParams* vparams) { const MassVector &masses= f_mass.getValue(); if (!vparams->displayFlags().getShowBehaviorModels()) return; const VecCoord& x = *mstate->getX(); for (unsigned int i=0; i<x.size(); i++) { if (masses[i].mass == 0) continue; Vec3d len; len[0] = len[1] = sqrt(masses[i].inertiaMatrix); len[2] = 0; Quat orient(Vec3d(0,0,1), x[i].getOrientation()); Vec3d center; center = x[i].getCenter(); vparams->drawTool()->drawFrame(center, orient, len*showAxisSize.getValue() ); } }
//! Draw any parts on the screen which are for our module void CompassMarks::draw(StelCore* core) { if (markFader.getInterstate() <= 0.0) { return; } Vec3d pos, screenPos; StelProjectorP prj = core->getProjection(StelCore::FrameAltAz, StelCore::RefractionOff); StelPainter painter(prj); painter.setFont(font); int f = 0; if (StelApp::getInstance().getFlagSouthAzimuthUsage()) f = 180; painter.setColor(markColor[0], markColor[1], markColor[2], markFader.getInterstate()); painter.setBlending(true); painter.setLineSmooth(true); for(int i=0; i<360; i++) { float a = i*M_PI/180; pos.set(sin(a),cos(a), 0.f); float h = -0.002; if (i % 15 == 0) { h = -0.02; // the size of the mark every 15 degrees QString s = QString("%1").arg((i+90+f)%360); float shiftx = painter.getFontMetrics().width(s) / 2.; float shifty = painter.getFontMetrics().height() / 2.; painter.drawText(pos, s, 0, -shiftx, shifty); } else if (i % 5 == 0) { h = -0.01; // the size of the mark every 5 degrees } // Limit arcs to those that are visible for improved performance if (prj->project(pos, screenPos) && screenPos[0]>prj->getViewportPosX() && screenPos[0] < prj->getViewportPosX() + prj->getViewportWidth()) { painter.drawGreatCircleArc(pos, Vec3d(pos[0], pos[1], h), Q_NULLPTR); } } painter.setBlending(false); painter.setLineSmooth(false); }
static void longLatLabel(const string& labelText, double longitude, double latitude, const Vec3d& viewRayOrigin, const Vec3d& viewNormal, const Vec3d& bodyCenter, const Quatd& bodyOrientation, const Vec3f& semiAxes, float labelOffset, Renderer* renderer) { double theta = degToRad(longitude); double phi = degToRad(latitude); Vec3d pos(cos(phi) * cos(theta) * semiAxes.x, sin(phi) * semiAxes.y, -cos(phi) * sin(theta) * semiAxes.z); float nearDist = renderer->getNearPlaneDistance(); pos = pos * (1.0 + labelOffset); double boundingRadius = max(semiAxes.x, max(semiAxes.y, semiAxes.z)); // Draw the label only if it isn't obscured by the body ellipsoid double t = 0.0; if (testIntersection(Ray3d(Point3d(0.0, 0.0, 0.0) + viewRayOrigin, pos - viewRayOrigin), Ellipsoidd(Vec3d(semiAxes.x, semiAxes.y, semiAxes.z)), t) && t >= 1.0) { // Compute the position of the label Vec3d labelPos = bodyCenter + (1.0 + labelOffset) * pos * bodyOrientation.toMatrix3(); // Calculate the intersection of the eye-to-label ray with the plane perpendicular to // the view normal that touches the front of the objects bounding sphere double planetZ = viewNormal * bodyCenter - boundingRadius; if (planetZ < -nearDist * 1.001) planetZ = -nearDist * 1.001; double z = viewNormal * labelPos; labelPos *= planetZ / z; renderer->addObjectAnnotation(NULL, labelText, Renderer::PlanetographicGridLabelColor, Point3f((float) labelPos.x, (float) labelPos.y, (float) labelPos.z)); } }
void RIMLS::Fit() { double f = 0; Vec3d grad_f(0, 0, 0); do { int i = 0; do { double sumW, sumF; sumW = sumF = 0; Vec3d sumGW, sumGF, sumN; sumGW = sumGF = sumN = Vec3d(0.0, 0.0, 0.0); for (DataPoint& p : m_neighbors) { Vec3d px = m_x - p.pos(); double fx = px.dot(p.normal()); double alpha = 1.0; if (i > 0) { alpha = exp(-pow((fx - f) / m_sigmaR, 2)) * exp(-pow((p.normal() - grad_f).norm() / m_sigmaN, 2)); } double phi = exp(-pow(px.norm() / m_sigmaT, 2)); double w = alpha*phi; Vec3d grad_w = -2.0*alpha*phi*px / pow(m_sigmaT, 2); sumW += w; sumGW += grad_w; sumF += w*fx; sumGF += grad_w*fx; sumN += w*p.normal(); } f = sumF / sumW; grad_f = (sumGF - f*sumGW + sumN) / sumW; } while (++i<m_iter && !convergence()); m_x -= f*grad_f; } while ((f*grad_f).norm() > m_threshold); }
void TestStelSphericalGeometry::testSphericalPolygon() { SphericalRegionP holySquare2 = bigSquare.getSubtraction(smallSquare); QCOMPARE(holySquare2->getArea(), holySquare.getArea()); //Booleans methods QCOMPARE(holySquare.getArea(), bigSquare.getArea()-smallSquare.getArea()); QCOMPARE(bigSquare.getUnion(holySquare)->getArea(), bigSquare.getArea()); QCOMPARE(bigSquare.getSubtraction(smallSquare)->getArea(), bigSquare.getArea()-smallSquare.getArea()); QCOMPARE(bigSquare.getIntersection(smallSquare)->getArea(), smallSquare.getArea()); // Point contain methods Vec3d v0, v1, v2; StelUtils::spheToRect(0.00000, 0.00000, v0); StelUtils::spheToRect(0.3, 0.3, v1); QVERIFY(smallSquareConvex.contains(v0)); QVERIFY(smallSquare.contains(v0)); QVERIFY(bigSquareConvex.contains(v0)); QVERIFY(bigSquare.contains(v0)); // FIXME: '!holySquare.contains(v0)' returned FALSE. //QVERIFY(!holySquare.contains(v0)); QVERIFY(!smallSquare.contains(v1)); QVERIFY(bigSquare.contains(v1)); QVERIFY(holySquare.contains(v1)); QVERIFY(holySquare.intersects(bigSquare)); QVERIFY(bigSquare.intersects(smallSquare)); QVERIFY(!holySquare.intersects(smallSquare)); SphericalCap cap(Vec3d(1,0,0), 0.99); QVERIFY(bigSquareConvex.intersects(cap)); // A case which caused a problem SphericalRegionP bug1 = SphericalRegionP::loadFromJson("{\"worldCoords\": [[[123.023842, -49.177087], [122.167613, -49.177087], [122.167613, -48.631248], [123.023842, -48.631248]]]}"); SphericalRegionP bug2 = SphericalRegionP::loadFromJson("{\"worldCoords\": [[[123.028902, -49.677124], [122.163995, -49.677124], [122.163995, -49.131382], [123.028902, -49.131382]]]}"); QVERIFY(bug1->intersects(bug2)); // Another one bug1 = SphericalRegionP::loadFromJson("{\"worldCoords\": [[[52.99403, -27.683551], [53.047302, -27.683551], [53.047302, -27.729923], [52.99403, -27.729923]]]}"); bug2 = SphericalRegionP::loadFromJson("{\"worldCoords\": [[[52.993701, -27.683092], [53.047302, -27.683092], [53.047302, -27.729839], [52.993701, -27.729839]]]}"); SphericalRegionP bugIntersect = bug1->getIntersection(bug2); }
void Game::SetModeReplay(const char* str){ FILE* fp; fopen_s(&fp,str,"r"); replayOrder.clear(); if(fp!=NULL){ int n,i,j,k; int c=0; while(fscanf_s(fp,"%d %d %d %d",&n,&i,&j,&k)==4){ replayOrder.push_back(Vec3d(0,0,0)); replayOrder[c].x=i; replayOrder[c].y=j; replayOrder[c].z=k; c++; } fclose(fp); replay=true; } }
MaterialPoint::MaterialPoint() { m_nextPos = Vec3d(0.0); m_pos = Vec3d(0.0); m_prevPos = Vec3d(0.0); m_nextVel = Vec3d(0.0); m_vel = Vec3d(0.0f); m_acceleration = Vec3d(0.0); m_mass = 1.0; m_radius = 0.0; m_stepCounter = 0; }
void TestStelSphericalGeometry::testSerialize() { // Store a SphericalPolygon as QVariant SphericalRegionP holyReg(new SphericalPolygon(holySquare)); QVariant vHolyReg = QVariant::fromValue(holyReg); QVERIFY(QString(vHolyReg.typeName())=="SphericalRegionP"); QVERIFY(vHolyReg.canConvert<SphericalRegionP>()); // and reconvert it SphericalRegionP reg2 = vHolyReg.value<SphericalRegionP>(); QCOMPARE(holyReg->getArea(), reg2->getArea()); QVERIFY(holyReg->getType()==reg2->getType()); // Store a SphericalCap as QVariant SphericalRegionP capReg(new SphericalCap(Vec3d(1,0,0), 0.12)); QVariant vCapReg = QVariant::fromValue(capReg); QVERIFY(QString(vCapReg.typeName())=="SphericalRegionP"); QVERIFY(vCapReg.canConvert<SphericalRegionP>()); // and reconvert it reg2 = vCapReg.value<SphericalRegionP>(); QCOMPARE(capReg->getArea(), reg2->getArea()); QVERIFY(capReg->getType()==reg2->getType()); // Test serialize the QVariants as binary QByteArray ar; QBuffer buf(&ar); buf.open(QIODevice::WriteOnly); QDataStream out(&buf); out << vHolyReg << vCapReg; buf.close(); QVERIFY(!ar.isEmpty()); // Re-read it QVariant readVCapReg, readVHolyReg; buf.open(QIODevice::ReadOnly); QDataStream in(&buf); in >> readVHolyReg >> readVCapReg; buf.close(); reg2 = readVHolyReg.value<SphericalRegionP>(); QCOMPARE(holyReg->getArea(), reg2->getArea()); QVERIFY(holyReg->getType()==reg2->getType()); reg2 = readVCapReg.value<SphericalRegionP>(); QCOMPARE(capReg->getArea(), reg2->getArea()); QVERIFY(capReg->getType()==reg2->getType()); }
void Driver::SurfAppendMesh(SurfTrack* g_surf,ObjModel& obj) { int oldVNum=g_surf->get_num_vertices(); for (int i = 0; i < obj.vertexNum; i++) { Vector3d& p=obj.vertex[i]; g_surf->add_vertex(Vec3d(p(0),p(1),p(2)),1.0f); } for (int i = 0; i < obj.faceNum; i++) { Face& f=obj.face[i]; int first=oldVNum+f.first-1; int second=oldVNum+f.second-1; int third=oldVNum+f.third-1; g_surf->add_triangle(Vec3st(first,second,third)); } }
Translate::Translate( istream& in, DofList* dofs ) { mIndex = 0; if ( dofs ) { char buf[1024]; in >> buf; assert(in); char* name = new char[strlen(buf)+1]; strcpy( name, buf ); double x,y,z; Vec3d range; in >> x >> y >> z >> range[0] >> range[1] >> range[2]; assert(in); mOffset = Vec3d(x,y,z); MakeDofs( name, *dofs, range); } else {