//---------------------------------------------------------------------------- void RoughPlaneParticle1::OnDisplay () { ClearScreen(); ColorRGB black(0, 0, 0); ColorRGB gray(128, 128, 128); ColorRGB blue(0, 0, 128); ColorRGB lightBlue(0, 0, 255); int x0, w0, x1, w1, i; Vector2d position; const double xScale = 1.25; const double wScale = 0.75; const int wOffset = 96; // Draw viscous friction path of motion. const int numVFPositions = (int)mVFPositions.size(); position = mVFPositions[0]; x0 = (int)(xScale*position.X() + 0.5); w0 = (int)(wScale*position.Y() + 0.5) + wOffset; x1 = x0; w1 = w0; for (i = 1; i < numVFPositions; ++i) { position = mVFPositions[i]; x1 = (int)(xScale*position.X() + 0.5); w1 = (int)(wScale*position.Y() + 0.5) + wOffset; DrawLine(x0, w0, x1, w1, lightBlue); x0 = x1; w0 = w1; } // Draw the mass. SetThickPixel(x1, w1, 2, blue); // Draw static friction path of motion. const int numSFPositions = (int)mSFPositions.size(); position = mSFPositions[0]; x0 = (int)(xScale*position.X() + 0.5); w0 = (int)(wScale*position.Y() + 0.5) + wOffset; x1 = x0; w1 = w0; for (i = 1; i < numSFPositions; ++i) { position = mSFPositions[i]; x1 = (int)(xScale*position.X() + 0.5); w1 = (int)(wScale*position.Y() + 0.5) + wOffset; DrawLine(x0, w0, x1, w1, gray); x0 = x1; w0 = w1; } // Draw the mass. SetThickPixel(x1, w1, 2, black); WindowApplication2::OnDisplay(); }
//---------------------------------------------------------------------------- Vector2d RoughPlaneParticle1::GetVFPosition (double time) { Vector2d position; double expValue = Mathd::Exp(-mR*time); position.X() = mA0*expValue + mA1; position.Y() = mB0*expValue + mB1*time + mB2; return position; }
void TerrainRenderManager::RenderBlock(RenderOptions& renderOptions, ViewFrustum3d& viewFrustum, unsigned int uiBlockX, unsigned int uiBlockY, const Vector2d& vBlockBase, const Vector3d& vBlockPosition) { if (m_renderDataMap.IsAvail(uiBlockX, uiBlockY)) { std::shared_ptr<IBlockRenderData> spRenderData = m_renderDataMap.Get(uiBlockX, uiBlockY); spRenderData->Update(vBlockPosition); glPushMatrix(); glTranslated(vBlockBase.X(), 0.0, vBlockBase.Y()); spRenderData->Render(renderOptions, viewFrustum); glPopMatrix(); } else { // TODO draw white rectangle as placeholder? } }
bool operator!=(const Vector2d& lhs, const Vector2d& rhs) { return lhs.X() != rhs.X() || lhs.Y() != rhs.Y(); }
Vector2d operator+(const Vector2d& lhs, const Vector2d& rhs) { return Vector2d(lhs.X() + rhs.X(), lhs.Y() + rhs.Y()); }
Vector2d operator/(const double v, const Vector2d& rhs) { return Vector2d(rhs.X() / v, rhs.Y() / v); }
Vector2d operator/(const Vector2d& lhs, const double v) { return Vector2d(lhs.X() / v, lhs.Y() / v); }
double operator*(const Vector2d& lhs, const Vector2d& rhs) { return lhs.X() * rhs.X() +lhs.Y() * rhs.Y(); }