void door(void) { initLeds(); col1(); col4(); col7(); _delay_ms(200); col1(); col5(); col9(); _delay_ms(200); col1(); col2(); col3(); _delay_ms(200); }
void FibreReader<DIM>::GetAllOrtho(std::vector< c_vector<double, DIM> >& first_direction, std::vector< c_vector<double, DIM> >& second_direction, std::vector< c_vector<double, DIM> >& third_direction) { assert(first_direction.empty()); assert(second_direction.empty()); assert(third_direction.empty()); if (mNumItemsPerLine != DIM*DIM) { EXCEPTION("Use GetAllAxi when reading axisymmetric fibres"); } for (unsigned i=0; i<mNumLinesOfData; i++) { c_matrix<double, DIM, DIM> temp_matrix; GetFibreSheetAndNormalMatrix(i, temp_matrix, true); //Note that although the matrix appears row-wise in the ascii .ortho file, //for convenience it is stored column-wise. matrix_column<c_matrix<double, DIM, DIM> > col0(temp_matrix, 0); first_direction.push_back(col0); if (DIM>=2) { matrix_column<c_matrix<double, DIM, DIM> > col1(temp_matrix, 1); second_direction.push_back(col1); } if (DIM==3) { matrix_column<c_matrix<double, DIM, DIM> > col2(temp_matrix, 2); third_direction.push_back(col2); } } }
BOOST_AUTO_TEST_CASE_TEMPLATE(create, T, float_types) { // default constructor vmath::core::Matrix<T, 3, 2> M_default; BOOST_CHECK_SMALL(M_default[0][0], static_cast<T>(1e-7)); BOOST_CHECK_SMALL(M_default[0][1], static_cast<T>(1e-7)); BOOST_CHECK_SMALL(M_default[0][2], static_cast<T>(1e-7)); BOOST_CHECK_SMALL(M_default[1][0], static_cast<T>(1e-7)); BOOST_CHECK_SMALL(M_default[1][1], static_cast<T>(1e-7)); BOOST_CHECK_SMALL(M_default[1][2], static_cast<T>(1e-7)); // parameterized constructor std::array<vmath::core::Vector<T, 3>, 2> data = {{ vmath::core::Vector<T, 3>(static_cast<T>(1.0), static_cast<T>(2.0), static_cast<T>(3.0)), vmath::core::Vector<T, 3>(static_cast<T>(4.0), static_cast<T>(5.0), static_cast<T>(6.0)) }}; vmath::core::Matrix<T, 3, 2> M_param(data); BOOST_CHECK_CLOSE(M_param[0][0], static_cast<T>(1.0), 1e-4f); BOOST_CHECK_CLOSE(M_param[0][1], static_cast<T>(2.0), 1e-4f); BOOST_CHECK_CLOSE(M_param[0][2], static_cast<T>(3.0), 1e-4f); BOOST_CHECK_CLOSE(M_param[1][0], static_cast<T>(4.0), 1e-4f); BOOST_CHECK_CLOSE(M_param[1][1], static_cast<T>(5.0), 1e-4f); BOOST_CHECK_CLOSE(M_param[1][2], static_cast<T>(6.0), 1e-4f); // parameterized constructor vmath::core::Vector<T, 3> col1(static_cast<T>(1.0), static_cast<T>(2.0), static_cast<T>(3.0)); vmath::core::Vector<T, 3> col2(static_cast<T>(4.0), static_cast<T>(5.0), static_cast<T>(6.0)); vmath::core::Matrix<T, 3, 2> M_param2(col1, col2); BOOST_CHECK_CLOSE(M_param2[0][0], static_cast<T>(1.0), 1e-4f); BOOST_CHECK_CLOSE(M_param2[0][1], static_cast<T>(2.0), 1e-4f); BOOST_CHECK_CLOSE(M_param2[0][2], static_cast<T>(3.0), 1e-4f); BOOST_CHECK_CLOSE(M_param2[1][0], static_cast<T>(4.0), 1e-4f); BOOST_CHECK_CLOSE(M_param2[1][1], static_cast<T>(5.0), 1e-4f); BOOST_CHECK_CLOSE(M_param2[1][2], static_cast<T>(6.0), 1e-4f); }
TEST(PaletteTranslator, BuildSortLuminance) { //uint32 y = r * 299 + g * 587 + b * 114; Color col0(0, 0, 10); Color col1(0, 0, 11); Color col2(10, 0, 0); Color col3(11, 0, 0); Color col4(0, 10, 0); Color col5(0, 11, 0); Palette pal; pal.m_count = 6; pal[0] = col3; pal[1] = col5; pal[2] = col1; pal[3] = col2; pal[4] = col4; pal[5] = col0; Palette exp; exp.m_count = 6; exp[0] = col0; exp[1] = col1; exp[2] = col2; exp[3] = col3; exp[4] = col4; exp[5] = col5; PaletteTranslator pt; pt.BuildSortLuminance(pal, nullptr); ASSERT_TRUE( pal == exp ); }
Matrix4 Matrix4::multiply(Matrix4 a) { Matrix4 b; /* for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { b.m[i][j] = m[0][j] * a.m[i][0] + m[1][j] * a.m[i][1] + m[2][j] * a.m[i][2] + m[3][j] * a.m[i][3]; } }*/ Vector4 row1(m[0][0], m[1][0], m[2][0], m[3][0]); Vector4 row2(m[0][1], m[1][1], m[2][1], m[3][1]); Vector4 row3(m[0][2], m[1][2], m[2][2], m[3][2]); Vector4 row4(m[0][3], m[1][3], m[2][3], m[3][3]); Vector4 col1(a.m[0][0], a.m[0][1], a.m[0][2], a.m[0][3]); Vector4 col2(a.m[1][0], a.m[1][1], a.m[1][2], a.m[1][3]); Vector4 col3(a.m[2][0], a.m[2][1], a.m[2][2], a.m[2][3]); Vector4 col4(a.m[3][0], a.m[3][1], a.m[3][2], a.m[3][3]); b.set(row1.dot(col1), row2.dot(col1), row3.dot(col1), row4.dot(col1), row1.dot(col2), row2.dot(col2), row3.dot(col2), row4.dot(col2), row1.dot(col3), row2.dot(col3), row3.dot(col3), row4.dot(col3), row1.dot(col4), row2.dot(col4), row3.dot(col4), row4.dot(col4)); return b; }
void ScreenAlignedText::tessellate(void) { //cout << "ScreenAlignedText::tessellate called" << endl; if( _mfText.empty() ) return; Text fontText; //SFSharedFontStylePtr *psfsp = getSFFont(); //SFSharedFontStyleWrapperPtr *wrapperPtr = getSFFont(); SharedFontStyleWrapperPtr wrapperPtr = getFont(); //SFSharedFontStylePtr psfsp = wrapperPtr->getSFFStyleContainer(); //SharedFontStylePtr psfs = psfsp->getValue(); SharedFontStylePtr psfs = wrapperPtr->getFStyleContainer(); if( psfs == NullFC ) { cerr << "ScreenAlignedText::tessellate: psfs = NullFC ! " << endl; return; } FontStyleP pFS = psfs->getContainedFontStyle(); if( pFS == NULL ) { cerr << "ScreenAlignedText::tessellate: pFS = NULL ! " << endl; return; } fontText.setFontStyle( pFS ); fontText.setJustifyMajor(MIDDLE_JT); // Colors are changed during rendering, // but are needed for // calling the fillImage routine Color4ub col1( 255, 255, 255, 255); Color4ub col2( 0, 0, 0, 0 ); ImagePtr pImg = Image::create(); std::vector<std::string> lineVec; for(unsigned int i = 0; i < _mfText.size(); i++ ) { lineVec.push_back( _mfText[i] ); } vector<NodePtr> cNodes; if(fontText.fillImage(pImg, lineVec, &col1, &col2, false, 0, 0, SET_TEX_TCM, CLEAR_ADD_MM, 1, true ) ) { _sfRenderImage.setValue( pImg ); } // cout << "ScreenAlignedText::tessellate(void)" << endl; }
/** * Decomposes matrix M such that T * R * S = M, where T is translation matrix, * R is rotation matrix and S is scaling matrix. * http://code.google.com/p/assimp-net/source/browse/trunk/AssimpNet/Matrix4x4.cs * (this method is exact to at least 0.0001f) * * | 1 0 0 T1 | | R11 R12 R13 0 | | a 0 0 0 | | aR11 bR12 cR13 T1 | * | 0 1 0 T2 |.| R21 R22 R23 0 |.| 0 b 0 0 | = | aR21 bR22 cR23 T2 | * | 0 0 0 T3 | | R31 R32 R33 0 | | 0 0 c 0 | | aR31 bR32 cR33 T3 | * | 0 0 0 1 | | 0 0 0 1 | | 0 0 0 1 | | 0 0 0 1 | * * @param m (in) matrix to decompose * @param scaling (out) scaling vector * @param rotation (out) rotation matrix * @param translation (out) translation vector */ void decomposeTRS(const glm::mat4& m, glm::vec3& translation, glm::mat4& rotation, glm::vec3& scaling) { // Extract the translation translation.x = m[3][0]; translation.y = m[3][1]; translation.z = m[3][2]; // Extract col vectors of the matrix glm::vec3 col1(m[0][0], m[0][1], m[0][2]); glm::vec3 col2(m[1][0], m[1][1], m[1][2]); glm::vec3 col3(m[2][0], m[2][1], m[2][2]); //Extract the scaling factors scaling.x = glm::length(col1); scaling.y = glm::length(col2); scaling.z = glm::length(col3); // Handle negative scaling if (glm::determinant(m) < 0) { scaling.x = -scaling.x; scaling.y = -scaling.y; scaling.z = -scaling.z; } // Remove scaling from the matrix if (scaling.x != 0) { col1 /= scaling.x; } if (scaling.y != 0) { col2 /= scaling.y; } if (scaling.z != 0) { col3 /= scaling.z; } rotation[0][0] = col1.x; rotation[0][1] = col1.y; rotation[0][2] = col1.z; rotation[0][3] = 0.0; rotation[1][0] = col2.x; rotation[1][1] = col2.y; rotation[1][2] = col2.z; rotation[1][3] = 0.0; rotation[2][0] = col3.x; rotation[2][1] = col3.y; rotation[2][2] = col3.z; rotation[2][3] = 0.0; rotation[3][0] = 0.0; rotation[3][1] = 0.0; rotation[3][2] = 0.0; rotation[3][3] = 1.0; }
int main() { zdb::Database database(L"test"); zdb::DbColumn col1(L"lalka1", DbDataType::Int32); zdb::DbColumn col2(L"lalka2", DbDataType::Int64); zdb::DbColumn col3(L"lalka3", DbDataType::Int8); std::vector<zdb::DbColumn> columns = { col1, col2, col3 }; database.AddTable(L"testTable", columns); return 0; }
void put_current_pixel(t_env *e, LG cx, LG cy, LG i) { if (!i) my_pixel_timage(cx - e->dat->currentx, cy - \ e->dat->currenty, e->dat->setcolornoi, e); else if (e->dat->col == '0') col(cx, cy, i, e); else col1(cx, cy, i, e); }
/* GLTexture::bgTex * Returns the global chequered 'background' texture *******************************************************************/ GLTexture& GLTexture::bgTex() { if (!tex_background.isLoaded()) { wxColour col1(bgtx_colour1); wxColour col2(bgtx_colour2); tex_background.genChequeredTexture(8, rgba_t(col1.Red(), col1.Green(), col1.Blue(), 255), rgba_t(col2.Red(), col2.Green(), col2.Blue(), 255)); } return tex_background; }
void CGpApp::DrawEnergyBar() { LC_RECTF rc1(0,0, (FLOAT)INT(1.5F * ENERGYBARmax), 16); LC_RECTF rc2(0,0, (FLOAT)INT(1.5F * ENERGYBARmax * m_ShieldEnergy / SHIELDENERGYmax), 16); LCXVECTOR2 vcTrn(0, m_nScnH - 20.0F); LCXCOLOR col2(1,0,0,0.7F); LCXCOLOR col1(0,0,1,0.7F); m_pSpt->DrawEx(NULL, &rc1, &vcTrn, NULL, NULL, 0, &col1); m_pSpt->Draw(NULL, &rc2, &vcTrn, &col2); }
//------------------------------------------------------------------------------- // @ IvRenderer::SetWorldMatrix() //------------------------------------------------------------------------------- // Sets the world matrix for the renderer //------------------------------------------------------------------------------- void IvRenderer::SetWorldMatrix(const IvMatrix44& matrix) { mWorldMat = matrix; mWVPMat = mProjectionMat*mViewMat*mWorldMat; IvMatrix33 worldMat3x3; IvVector3 col0(mWorldMat(0,0), mWorldMat(1,0), mWorldMat(2,0)); IvVector3 col1(mWorldMat(0,1), mWorldMat(1,1), mWorldMat(2,1)); IvVector3 col2(mWorldMat(0,2), mWorldMat(1,2), mWorldMat(2,2)); worldMat3x3.SetColumns(col0, col1, col2); mNormalMat.Rotation(Transpose(Inverse(worldMat3x3))); }
LOCAL_C void CreateTable() { CDbColSet *cs=CDbColSet::NewLC(); TDbCol col1(KColumnInt,EDbColInt32); col1.iAttributes=TDbCol::ENotNull; cs->AddL(col1); TDbCol col2(KColumnText,EDbColText,200/sizeof(TText)); col2.iAttributes=TDbCol::ENotNull; cs->AddL(col2); test(TheDatabase.CreateTable(KTableName,*cs)==KErrNone); CleanupStack::PopAndDestroy(); }
void ColumnMajorMatrixTest::ThreeColConstructor() { VectorValue<Real> col1( 1, 2, 3 ); VectorValue<Real> col2( 4, 5, 6 ); VectorValue<Real> col3( 7, 8, 9 ); ColumnMajorMatrix test( col1, col2, col3 ); CPPUNIT_ASSERT( test == *a ); CPPUNIT_ASSERT( test.numEntries() == 9 ); }
// extract frustum plane in world space. // the normals facing inward. // pass in view * projection matrix. void Frustum::InitFromMatrix(const Matrix &VP) { // near and far plane corners static float3 verts[8] = { // near plane corners float3( -1, -1,0 ), float3( 1, -1,0 ), float3( 1, 1,0 ), float3( -1, 1 ,0), // far plane corners. float3( -1, -1 ,1), float3( 1, -1,1 ), float3( 1, 1,1 ), float3( -1, 1,1 ) }; this->m_matrix = VP; float4 col0(VP(0,0), VP(1,0), VP(2,0), VP(3,0)); float4 col1(VP(0,1), VP(1,1), VP(2,1), VP(3,1)); float4 col2(VP(0,2), VP(1,2), VP(2,2), VP(3,2)); float4 col3(VP(0,3), VP(1,3), VP(2,3), VP(3,3)); // Planes face inward. m_planes[Near] = Plane(col2); // near m_planes[Far] = Plane(col3 - col2); // far m_planes[Left] = Plane(col3 + col0); // left m_planes[Right] = Plane(col3 - col0); // right m_planes[Top] = Plane(col3 - col1); // top m_planes[Bottom] = Plane(col3 + col1); // bottom // normalize all six planes for(int i = 0; i < 6; i++) { m_planes[i].Normalize(); } // tranform eight corner from device coordiate to world coordinate. Matrix invVP = VP; invVP.Invert(); for(int i = 0; i < 8; i++) { this->m_corners[i] = float3::Transform(verts[i],invVP); } }
void wxZEdit::EndPanel() { wxCaptionBarStyle style; wxColour col1(193,208,233), col2(49,106,197); style.SetFirstColour(col1); style.SetSecondColour(col2); style.SetCaptionStyle(wxCAPTIONBAR_FILLED_RECTANGLE); m_pnl->ApplyCaptionStyleAll(style); // ask for a resize wxSizeEvent mevent( GetSize()+wxSize(1,1), GetId() ); mevent.SetEventObject( this ); ProcessEvent( mevent ); }
// // Look at the materials of this level's edges. If they all use the // same material, return it. Otherwise, return BMAT_UNKNOWN. // bool vtLevel::GetOverallEdgeColor(RGBi &color) { RGBi col1(-1, -1, -1); int edges = NumEdges(); for (int i = 0; i < edges; i++) { vtEdge *pEdge = GetEdge(i); RGBi col2 = pEdge->m_Color; if (col1.r == -1) col1 = col2; else if (col1 != col2) return false; } color = col1; return true; }
/*---------------------------------------------------------------------*//** 次のストーリーを予約 **//*---------------------------------------------------------------------*/ void StoryManager::reserveNextStory(s32 storyid) { // ストーリーを予約 ASSERT(_storyidReserved == 0); _storyidReserved = storyid; // 次のストーリー開始まで、たいていの場合、 // フェードアウトとフェードインの間の画面が表示されてしまうので、 // 1フレームの塗りつぶしを入れる ScreenEffect* screff = Game::getGame()->getSceneScreenEffect(); // 色設定 ColorU8 col1(0, 0, 0, 255); screff->setColor1(&col1); // 現仕様では黒のみ対応 // フレーム数設定 screff->setMaxFrame(1); // 実行 screff->start(ScreenEffect::MODE_FILL); }
//============================================================================== void DebugDrawer::drawGrid() { Vec4 col0(0.5, 0.5, 0.5, 1.0); Vec4 col1(0.0, 0.0, 1.0, 1.0); Vec4 col2(1.0, 0.0, 0.0, 1.0); const F32 SPACE = 1.0; // space between lines const U NUM = 57; // lines number. must be odd const F32 GRID_HALF_SIZE = ((NUM - 1) * SPACE / 2); setColor(col0); begin(GL_LINES); for(U x = - NUM / 2 * SPACE; x < NUM / 2 * SPACE; x += SPACE) { setColor(col0); // if the middle line then change color if(x == 0) { setColor(col1); } // line in z pushBackVertex(Vec3(x, 0.0, -GRID_HALF_SIZE)); pushBackVertex(Vec3(x, 0.0, GRID_HALF_SIZE)); // if middle line change col so you can highlight the x-axis if(x == 0) { setColor(col2); } // line in the x pushBackVertex(Vec3(-GRID_HALF_SIZE, 0.0, x)); pushBackVertex(Vec3(GRID_HALF_SIZE, 0.0, x)); } // render end(); }
void Camera::buildFrustumPlanes() { D3DXMATRIX VP = m_view * m_proj; D3DXVECTOR4 col0(VP(0, 0), VP(1, 0), VP(2, 0), VP(3, 0)); D3DXVECTOR4 col1(VP(0, 1), VP(1, 1), VP(2, 1), VP(3, 1)); D3DXVECTOR4 col2(VP(0, 2), VP(1, 2), VP(2, 2), VP(3, 2)); D3DXVECTOR4 col3(VP(0, 3), VP(1, 3), VP(2, 3), VP(3, 3)); // Planes face inward. mFrustumPlanes[0] = (D3DXPLANE)(col2); // near mFrustumPlanes[1] = (D3DXPLANE)(col3 - col2); // far mFrustumPlanes[2] = (D3DXPLANE)(col3 + col0); // left mFrustumPlanes[3] = (D3DXPLANE)(col3 - col0); // right mFrustumPlanes[4] = (D3DXPLANE)(col3 - col1); // top mFrustumPlanes[5] = (D3DXPLANE)(col3 + col1); // bottom for (int i = 0; i < 6; i++) D3DXPlaneNormalize(&mFrustumPlanes[i], &mFrustumPlanes[i]); }
bool CopyArrayOperator:: SplitDisconnectedUnit( DepCompCopyArrayCollect& collect, DepCompCopyArrayCollect::CopyArrayUnit& unit, DepCompAstRefGraphCreate& refDep, DepCompCopyArrayCollect::CopyArrayUnit::NodeSet& cuts) { assert(unit.refs.size() > 0); DepCompCopyArrayCollect::CopyArrayUnit::InsideGraph insidegraph(&refDep,unit); const DepCompAstRefGraphNode* cur = *unit.refs.begin(); GraphGetNodeReachable<DepCompCopyArrayCollect::CopyArrayUnit::InsideGraph, AppendPtrSet<const DepCompAstRefGraphNode> > op; DepCompCopyArrayCollect::CopyArrayUnit::NodeSet innodes; AppendPtrSet<const DepCompAstRefGraphNode> col1(innodes), col2(cuts); op(&insidegraph, cur, GraphAccess::EdgeIn,col1); for (DepCompCopyArrayCollect::CopyArrayUnit::NodeSet::const_iterator p1 = innodes.begin(); !p1.ReachEnd(); ++p1) { op(&insidegraph, (*p1), GraphAccess::EdgeOut,col2); } cuts |= innodes; return cuts.size() < unit.refs.size(); }
TextureManager::TextureManager() { sf::Image textureimage; textureimage.create(32, 32, sf::Color(255, 0, 0)); sf::Color col1(254, 254, 234); sf::Color col2(0, 72, 180); for(int i = 0; i < 32; ++i) { for(int j = i * 0.5; j < 32 - (i * 0.5); ++j) { textureimage.setPixel(i, j, col1); } } for(int i = 0; i < 32; ++i) { textureimage.setPixel(31, i, col2); textureimage.setPixel(i, 31, col2); } fallbacktexture = new sf::Texture(); fallbacktexture->loadFromImage(textureimage); }
TEST(PaletteTranslator, BuildDuplicatedColors) { Color col0(11, 12, 13); Color col1(14, 15, 16); Color col2(20, 21, 22, 0); Color col3(11, 12, 13); Color col4(30, 31, 32, 0); Palette pal; pal.m_count = 5; pal[0] = col0; pal[1] = col1; pal[2] = col2; pal[3] = col3; pal[4] = col4; Palette exp; exp.m_count = 3; exp[0] = col0; exp[1] = col1; exp[2] = col2; uint32 colCounts[256] = { 1, 10, 100, 1000, 10000 }; uint32 expectedColCounts[256] = { 1001, 10, 10100, 0, 0 }; PaletteTranslator pt; pt.BuildDuplicatedColors(pal, colCounts); ASSERT_TRUE( pal == exp ); ASSERT_TRUE( memcmp(colCounts, expectedColCounts, sizeof(colCounts)) == 0 ); uint8 pixels[] = { 0, 1, 2, 3, 4 }; const uint8 expectedPixels[] = { 0, 1, 2, 0, 2 }; pt.Translate(pixels, sizeof(pixels)); ASSERT_TRUE( memcmp(pixels, expectedPixels, sizeof(pixels)) == 0 ); }
int Lua_Color_Equal(LuaPlus::LuaState *lua) { LuaPlus::LuaStack args(lua); float a[2]={0}, r[2]={0}, g[2]={0}, b[2]={0}; if (args.Count()==2) { for (int i=0; i<2; i++) { if (args[i+1].IsTable()) { if (args[i+1]["a"].IsNumber()) a[i]=args[i+1]["a"].GetFloat(); if (args[i+1]["r"].IsNumber()) r[i]=args[i+1]["r"].GetFloat(); if (args[i+1]["g"].IsNumber()) g[i]=args[i+1]["g"].GetFloat(); if (args[i+1]["b"].IsNumber()) b[i]=args[i+1]["b"].GetFloat(); } } } RUGE::CColor col1(a[0], r[0], g[0], b[0]), col2(a[1], r[1], g[1], b[1]); lua->PushBoolean(col1==col2 ? true : false); return 1; }
void KNDdeTorusCollocation::init(const KNVector& sol, const KNVector& par) { double* t1 = new double[NTAU+1]; double* t2 = new double[NTAU+1]; for (size_t i2 = 0; i2 < nint2; i2++) { for (size_t i1 = 0; i1 < nint1; i1++) { for (size_t j2 = 0; j2 < ndeg2; j2++) { for (size_t j1 = 0; j1 < ndeg1; j1++) { const size_t idx = idxmap(j1, j2, i1, i2); // this is a unique time1(idx) = ((double)i1 + col1(j1)) / nint1; time2(idx) = ((double)i2 + col2(j2)) / nint2; } } } } sys->p_tau(p_tau, time1, par); p_xx.clear(); for (size_t idx = 0; idx < time1.size(); ++idx) { t1[0] = time1(idx); t2[0] = time2(idx); for (size_t k = 0; k < NTAU; k++) { t1[1+k] = (t1[0] - p_tau(k,idx) / par(0)) - floor(t1[0] - p_tau(k,idx) / par(0)); t2[1+k] = (t2[0] - par(RHO) * p_tau(k,idx) / par(0)) - floor(t2[0] - par(RHO) * p_tau(k,idx) / par(0)); } for (size_t k = 0; k < NTAU + 1; k++) { size_t i1 = static_cast<size_t>(floor(nint1 * t1[k])); size_t i2 = static_cast<size_t>(floor(nint2 * t2[k])); // some error checking if ((t1[k] > 1.0) || (t2[k] > 1.0) || (t1[k] < 0.0) || (t2[k] < 0.0)) std::cout << "Er "; if ((i1 >= nint1) || (i2 >= nint2)) std::cout << "Ei "; // end error checking for (size_t j2 = 0; j2 < ndeg2 + 1; j2++) { for (size_t j1 = 0; j1 < ndeg1 + 1; j1++) { const size_t idxKK = idxkk(j1, j2, k); kk(idxKK,idx) = idxmap(j1, j2, i1, i2); ee(idxKK,idx) = idxKK; } } } // sorting comp aa(kk.pointer(0,idx)); std::sort(ee.pointer(0,idx), ee.pointer(0,idx) + (NTAU + 1)*(ndeg1 + 1)*(ndeg2 + 1), aa); // filtering same indices rr(ee(0,idx),idx) = 0; size_t nz = 0; for (size_t i = 1; i < (NTAU + 1)*(ndeg1 + 1)*(ndeg2 + 1); i++) { if (kk(ee(i-1,idx),idx) != kk(ee(i,idx),idx)) nz++; rr(ee(i,idx),idx) = nz; } // interpolate the solution for (size_t k = 1; k < NTAU + 1; k++) { const double c1 = nint1 * t1[k] - floor(nint1 * t1[k]); const double c2 = nint2 * t2[k] - floor(nint2 * t2[k]); for (size_t j2 = 0; j2 < ndeg2 + 1; j2++) { for (size_t j1 = 0; j1 < ndeg1 + 1; j1++) { const size_t idxKK = idxkk(j1, j2, k); const double cf = poly_lgr_eval(mesh1, j1, c1) * poly_lgr_eval(mesh2, j2, c2); for (size_t p = 0; p < NDIM; p++) { p_xx(p, k - 1, idx) += cf * sol(p + NDIM * kk(idxKK, idx)); } } } } // derivatives at all delays for (size_t k = 0; k < NTAU + 1; k++) { const double c1 = nint1 * t1[k] - floor(nint1 * t1[k]); const double c2 = nint2 * t2[k] - floor(nint2 * t2[k]); for (size_t j2 = 0; j2 < ndeg2 + 1; j2++) { for (size_t j1 = 0; j1 < ndeg1 + 1; j1++) { const size_t idxKK = idxkk(j1, j2, k); const double cf1 = poly_dlg_eval(mesh1, j1, c1) * nint1 * poly_lgr_eval(mesh2, j2, c2); const double cf2 = poly_lgr_eval(mesh1, j1, c1) * poly_dlg_eval(mesh2, j2, c2) * nint2; for (size_t p = 0; p < NDIM; p++) { p_xx(p, NTAU + 2*k, idx) += cf1 * sol(p + NDIM * kk(idxKK, idx)); p_xx(p, NTAU + 2*k + 1, idx) += cf2 * sol(p + NDIM * kk(idxKK, idx)); } } } } } // for (int idx = 0; idx < time1.size(); ++idx) std::cout<<p_xx(0, NTAU, idx)<<"\t"; // std::cout<<"\np_xx(0,...) was\n"; delete[] t2; delete[] t1; }
bool ossim::matrixToHpr( ossim_float64 hpr[3], const NEWMAT::Matrix& rotation ) { //implementation converted from plib's sg.cxx //PLIB - A Suite of Portable Game Libraries //Copyright (C) 1998,2002 Steve Baker //For further information visit http://plib.sourceforge.net NEWMAT::Matrix mat(rotation); ossimDpt3d col1(rotation[0][0], rotation[1][0], rotation[2][0]); double s = col1.length(); hpr[0] = 0.0; hpr[1] = 0.0; hpr[2] = 0.0; if ( s <= 0.00001 ) { return true; } double oneOverS = 1.0f / s; for( int i = 0; i < 3; i++ ) for( int j = 0; j < 3; j++ ) mat[i][j] = rotation[j][i] * oneOverS; hpr[1] = ossim::asind(ossim::clamp(mat[1][2], -1.0, 1.0)); double cp = ossim::cosd(hpr[1]); if ( cp > -0.00001 && cp < 0.00001 ) { double cr = ossim::clamp(mat[0][1], -1.0, 1.0); double sr = ossim::clamp(-mat[2][1], -1.0, 1.0); hpr[0] = 0.0f; hpr[2] = ossim::atan2d(sr,cr); } else { cp = 1.0 / cp; double sr = ossim::clamp((-mat[0][2] * cp), -1.0,1.0); double cr = ossim::clamp((mat[2][2] * cp), -1.0, 1.0); double sh = ossim::clamp((-mat[1][0] * cp), -1.0, 1.0); double ch = ossim::clamp((mat[1][1] * cp), -1.0, 1.0); if ( (sh == 0.0f && ch == 0.0f) || (sr == 0.0f && cr == 0.0f) ) { cr = ossim::clamp(mat[0][1], -1.0, 1.0); sr = ossim::clamp(-mat[2][1], -1.0, 1.0); hpr[0] = 0.0f; } else { hpr[0] = ossim::atan2d(sh, ch); } hpr[2] = ossim::atan2d(sr, cr); } hpr[0] *= -1.0; return true; }
int main(void) { int firmver; char eingabe[20]; char *file; char row, col, row2, col2; long int *ticker; struct padtime mytime; char seribyte; eingabe[0] = 0; firmver=padgetversion(); SNDCHAL = 50; SNDCHAH = 30; ticker = padgetticker(); printf("Ticker is: %li\n", *ticker); padgettime(&mytime); printf("Address is: %u\n", (unsigned int)mytime); printf("Date: %i.%i. Time is %i:%i:%i\n", mytime.month, mytime.date, mytime.hour, mytime.minute, mytime.second); while(1) { while(!padserialwaiting()); printf("Serial data waiting...\n"); padinserial(&seribyte); printf("Byte: %02x\n", seribyte); padoutserial(seribyte + 1); } getchar(); // txtsetwindow(10,1,50,6); if(txtgetwindow(&col, &row, &col2, &row2)) { printf("The window coordinates are (%i,%i) - (%i,%i)\n", col, row, col2, row2); } txtoutput(65); txtwrchar(66); printf("Current Time: %s\n", dasciitime); txtsetcursor(1,1); printf("C on the Amstrad Notepad, Build %i\n", BUILD); txtboldon(); printf("Your firmware version is: %i, mmu0 is %02X\n", firmver,copyofmmu0); txtboldoff(); printf("Please enter your name:"); kmcharreturn(65); txtcuroff(); if (editbuf(eingabe, 20, EDITBUF_DOTTY)) { txtgetcursor(&col, &row); printf("\nYour name is %s and the cursor was at (%i, %i)\n", eingabe, col, row); } else { printf("\nOk, you're to shy!\n"); } txtcuron(); getchar(); txtclearwindow(); printf("\nPress any key to continue"); kmsettickcount(0,0); kmwaitkbd(); col1(); printf("Press a key to quit!"); kmwaitkbd(); file = selectfile(); if (file == NULL) { printf("Don't you want to view a file?\n"); } else { printf("Your file was %s!\n", file); } kmwaitkbd(); // getchar(); return 0; }
void GLUI_Translation::draw_2d_arrow( int radius, int filled, int orientation ) { float x1 = .2, x2 = .4, y1 = .54, y2 = .94, y0; float x1a, x1b; vec3 col1( 0.0, 0.0, 0.0 ), col2( .45, .45, .45 ), col3( .7, .7, .7 ), col4( 1.0, 1.0, 1.0 ); vec3 c1, c2, c3, c4, c5, c6; vec3 white(1.0,1.0,1.0), black(0.0,0.0,0.0), gray(.45,.45,.45), bkgd(.7,.7,.7); int c_off; /* color index offset */ if ( glui ) bkgd.set(glui->bkgd_color_f[0], glui->bkgd_color_f[1], glui->bkgd_color_f[2]); /* bkgd[0] = 255.0; bkgd[1] = 0; */ /** The following 8 colors define the shading of an octagon, in clockwise order, starting from the upstroke on the left **/ /** This is for an outside and inside octagons **/ vec3 colors_out[]={white, white, white, gray, black, black, black, gray}; vec3 colors_in[] ={bkgd,white,bkgd,gray,gray,gray,gray,gray}; #define SET_COL_OUT(i) glColor3fv((float*) &colors_out[(i)%8][0]); #define SET_COL_IN(i) glColor3fv((float*) &colors_in[(i)%8][0]); x1 = (float)radius * .2; x2 = x1 * 2; y1 = (float)radius * .54; y2 = y1 + x2; x1a = x1; x1b = x1; glMatrixMode(GL_MODELVIEW); glPushMatrix(); #define DRAW_SEG( xa,ya,xb,yb ) glVertex2f(xa,ya); glVertex2f(xb,yb); glScalef( -1.0, 1.0, 1.0 ); if ( orientation == 2 ) { c_off = 4; } else if ( orientation == 0 ) { c_off = 0; glRotatef( 180.0, 0.0, 0.0, 1.0 ); } else if ( orientation == 1 ) { c_off = 2; glRotatef( 90.0, 0.0, 0.0, 1.0 ); } else if ( orientation == 3 ) { c_off = 6; glRotatef( -90.0, 0.0, 0.0, 1.0 ); } if ( trans_type == GLUI_TRANSLATION_Z ) y0 = 0.0; else if ( trans_type == GLUI_TRANSLATION_XY ) y0 = x1; else y0 = 0.0; if ( trans_type == GLUI_TRANSLATION_Z ) { if ( orientation == 0 ) { y1 += 2.0; y2 += 0.0; x1b -= 2.0; x2 -= 2.0; x1a += 2.0; } else if ( orientation == 2 ) { y1 -= 6.0; x1a += 2.0; x1b += 4.0; x2 += 6.0; } } /*** Fill in inside of arrow ***/ if ( NOT filled ) { /*** Means button is up - control is not clicked ***/ /*glColor3f( .8, .8, .8 ); */ set_to_bkgd_color(); glColor3f( bkgd[0]+.07, bkgd[1]+.07, bkgd[2]+.07 ); } else { /*** Button is down on control ***/ glColor3f( .6, .6, .6 ); c_off += 4; /* Indents the shadows - goes from a raised look to embossed */ } /*** Check if control is enabled or not ***/ if ( NOT enabled ) { set_to_bkgd_color(); /*c_off += 4; -- Indents the shadows - goes from a raised look to embossed */ colors_out[0] = colors_out[1] = colors_out[2] = colors_out[7] = gray; colors_out[3] = colors_out[4] = colors_out[5] = colors_out[6] = white; colors_in[0] = colors_in[1] = colors_in[2] = colors_in[7] = white; colors_in[3] = colors_in[4] = colors_in[5] = colors_in[6] = gray; } glBegin( GL_POLYGON ); glVertex2f( 0.0, 0.0 ); glVertex2f( -x1a, 0.0 ); glVertex2f( -x1a, 0.0 ); glVertex2f( -x1b, y1 ); glVertex2f( x1b, y1); glVertex2f( x1a, 0.0 ); glVertex2f( x1a, 0.0 ); glVertex2f( 0.0, 0.0 ); glEnd(); glBegin( GL_TRIANGLES ); glVertex2f( -x2, y1 ); glVertex2f( 0.0, y2 ); glVertex2f( x2, y1 ); glEnd(); glLineWidth( 1.0 ); /*** Draw arrow outline ***/ glBegin( GL_LINES ); SET_COL_IN(1+c_off); DRAW_SEG( 0.0, y2-1.0, -x2, y1-1.0 ); SET_COL_IN(6+c_off); DRAW_SEG( -x2+2.0, y1+1.0, -x1b+1.0, y1+1.0 ); SET_COL_IN(0+c_off); DRAW_SEG( -x1b+1.0, y1+1.0, -x1a+1.0, y0 ); SET_COL_IN(3+c_off); DRAW_SEG( 0.0, y2-1.0, x2, y1-1.0 ); SET_COL_IN(6+c_off); DRAW_SEG( x2-1.0, y1+1.0, x1b-1.0, y1+1.0 ); SET_COL_IN(4+c_off); DRAW_SEG( x1b-1.0, y1+1.0, x1a-1.0, y0 ); SET_COL_OUT(0+c_off); DRAW_SEG( -x1a, y0, -x1b, y1 ); SET_COL_OUT(6+c_off); DRAW_SEG( -x1b, y1, -x2, y1 ); SET_COL_OUT(1+c_off); DRAW_SEG( -x2, y1, 0.0, y2 ); SET_COL_OUT(3+c_off); DRAW_SEG( 0.0, y2, x2, y1 ); SET_COL_OUT(6+c_off); DRAW_SEG( x2, y1, x1b, y1 ); SET_COL_OUT(4+c_off); DRAW_SEG( x1b, y1, x1a, y0 ); glEnd(); #undef DRAW_SEG glPopMatrix(); }
//----- paintGL ---------------------------------------------- void QGLWidgetTest::paintGL() { GInt32 i, j, k, w, ofs; GPoint<GDouble, 2> a, b, c; GPoint2 p1, p2; GPoint<GDouble, 3> col1(1.0f, 0.74f, 0.2f); GPoint<GDouble, 3> col2(0.4f, 0.1f, 0.6f); GPoint<GDouble, 3> col; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); setLightAndTransform(); glDisable(GL_LINE_SMOOTH); glLineWidth(1.0f); if (gFillDraw) { k = gTriangles.size() / 3; glBegin(GL_TRIANGLES); for (i = 0; i < k; i++) { a = gTriangles[i * 3]; b = gTriangles[i * 3 + 1]; c = gTriangles[i * 3 + 2]; col = GMath::Lerp(GMath::Clamp(a[G_Y], (GDouble)0, (GDouble)1), col1, col2); glColor3d(col[0], col[1], col[2]); glVertex3d(a[G_X], a[G_Y], 1.0f); col = GMath::Lerp(GMath::Clamp(b[G_Y], (GDouble)0, (GDouble)1), col1, col2); glColor3d(col[0], col[1], col[2]); glVertex3d(b[G_X], b[G_Y], 1.0f); col = GMath::Lerp(GMath::Clamp(c[G_Y], (GDouble)0, (GDouble)1), col1, col2); glColor3d(col[0], col[1], col[2]); glVertex3d(c[G_X], c[G_Y], 1.0f); } glEnd(); if (!gWireFrame) return; glLineWidth(1.0f); glBegin(GL_LINES); glColor3f(1.0f, 1.0f, 1.0f); for (i = 0; i < k; i++) { a = gTriangles[i * 3]; b = gTriangles[i * 3 + 1]; c = gTriangles[i * 3 + 2]; glVertex3d(a[G_X], a[G_Y], 1.0f); glVertex3d(b[G_X], b[G_Y], 1.0f); glVertex3d(a[G_X], a[G_Y], 1.0f); glVertex3d(c[G_X], c[G_Y], 1.0f); glVertex3d(b[G_X], b[G_Y], 1.0f); glVertex3d(c[G_X], c[G_Y], 1.0f); } glEnd(); } else { glBegin(GL_LINES); glColor3f(1.0f, 1.0f, 1.0f); j = gIndex.size(); ofs = 0; for (i = 0; i < j; i++) { k = gIndex[i]; for (w = 0; w < k - 1; w++) { p1 = gVertices[ofs + w]; p2 = gVertices[ofs + w + 1]; glVertex3f(p1[G_X], p1[G_Y], 1.0f); glVertex3f(p2[G_X], p2[G_Y], 1.0f); } p1 = gVertices[ofs + k - 1]; p2 = gVertices[ofs]; glVertex3f(p1[G_X], p1[G_Y], 1.0f); glVertex3f(p2[G_X], p2[G_Y], 1.0f); ofs += k; } glEnd(); } glFlush(); }
void FolderContent::OnPaint() { BlockDrawing(); axGC* gc = GetGC(); axRect rect0(axPoint(0, 0), GetRect().size); gc->SetColor(axColor(0.9, 0.9, 0.9), 1.0); gc->DrawRectangle(axRect(1, 1, rect0.size.x - 2, rect0.size.y -1)); // Folder Content. axColor col1(0.7, 0.7, 0.7); axColor col2(0.8, 0.8, 0.8); int y = 0; int x = 40; gc->SetFontSize(12); deque<DirectoryNavigation::FileInfo>& dirNames = *_dirNavigation->GetFileInfoDeque(); for(int i = 0; i < dirNames.size(); i++) { if(i % 2) gc->SetColor(col1); else gc->SetColor(col2); // Draw file background. axRect backfileRect(1, y, rect0.size.x - 1, 24); gc->DrawRectangle(backfileRect); // Draw file highlight. if(_selected_file == i) { gc->SetColor(axColor(0.7, 0.7, 1.0), 0.5); axRect selected_rect(1, y, rect0.size.x - 2, 24); gc->DrawRectangle(selected_rect); gc->DrawRectangleColorFade(selected_rect, axColor(0.7, 0.7, 0.7), 0.5, axColor(0.8, 0.8, 0.8), 0.5); } // Draw file icon. if(dirNames[i].second != DirectoryNavigation::ICON_NONE) { gc->DrawImageResize(_icons[dirNames[i].second], axPoint(3, y), axSize(24, 24)); } // Draw file name. gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0); gc->DrawString(dirNames[i].first, axPoint(x, y+4)); y += 24; if(i > 30) { break; } } gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0); gc->DrawRectangleContour(axRect(1, 1, rect0.size.x - 1, rect0.size.y - 1)); UnBlockDrawing(); }