void CAsteroid::SetVel(const CVector2& vel) { m_Vel = vel; // This is a screensave so we need to make sure we never get a velocity of zero // If we do we might burn in an asteroid on the screen if (SquareMagnitude(m_Vel) < 0.1f) { m_Vel.Set(0.1f, RandSFloat()*0.1f); } }
D3DVALUE Magnitude (const UniVector& v) { return (D3DVALUE) sqrt(SquareMagnitude(v)); }
float Vector4::Magnitude() const { return sqrtf( SquareMagnitude() ); }
bool CAsteroid::Intersects(const CVector2& pos) { if (SquareMagnitude(m_Pos-pos) < SQR(m_Size)) return true; return false; }
vector3 TGeometry::Load(TQueryParserComp *Parser) { str = Parser->GetNextSymbol().LowerCase(); tmp->TextureID = TTexturesManager::GetTextureID(str.c_str()); i = 0; do { tf = Parser->GetNextSymbol().ToDouble(); TempVerts[i].Point.x = tf; tf = Parser->GetNextSymbol().ToDouble(); TempVerts[i].Point.y = tf; tf = Parser->GetNextSymbol().ToDouble(); TempVerts[i].Point.z = tf; tf = Parser->GetNextSymbol().ToDouble(); TempVerts[i].Normal.x = tf; tf = Parser->GetNextSymbol().ToDouble(); TempVerts[i].Normal.y = tf; tf = Parser->GetNextSymbol().ToDouble(); TempVerts[i].Normal.z = tf; str = Parser->GetNextSymbol().LowerCase(); if (str == "x") TempVerts[i].tu = (TempVerts[i].Point.x + Parser->GetNextSymbol().ToDouble()) / Parser->GetNextSymbol().ToDouble(); else if (str == "y") TempVerts[i].tu = (TempVerts[i].Point.y + Parser->GetNextSymbol().ToDouble()) / Parser->GetNextSymbol().ToDouble(); else if (str == "z") TempVerts[i].tu = (TempVerts[i].Point.z + Parser->GetNextSymbol().ToDouble()) / Parser->GetNextSymbol().ToDouble(); else TempVerts[i].tu = str.ToDouble(); ; str = Parser->GetNextSymbol().LowerCase(); if (str == "x") TempVerts[i].tv = (TempVerts[i].Point.x + Parser->GetNextSymbol().ToDouble()) / Parser->GetNextSymbol().ToDouble(); else if (str == "y") TempVerts[i].tv = (TempVerts[i].Point.y + Parser->GetNextSymbol().ToDouble()) / Parser->GetNextSymbol().ToDouble(); else if (str == "z") TempVerts[i].tv = (TempVerts[i].Point.z + Parser->GetNextSymbol().ToDouble()) / Parser->GetNextSymbol().ToDouble(); else TempVerts[i].tv = str.ToDouble(); ; // tf= Parser->GetNextSymbol().ToDouble(); // TempVerts[i].tu= tf; // tf= Parser->GetNextSymbol().ToDouble(); // TempVerts[i].tv= tf; TempVerts[i].Point.RotateZ(aRotate.z / 180 * M_PI); TempVerts[i].Point.RotateX(aRotate.x / 180 * M_PI); TempVerts[i].Point.RotateY(aRotate.y / 180 * M_PI); TempVerts[i].Normal.RotateZ(aRotate.z / 180 * M_PI); TempVerts[i].Normal.RotateX(aRotate.x / 180 * M_PI); TempVerts[i].Normal.RotateY(aRotate.y / 180 * M_PI); TempVerts[i].Point += pOrigin; tmp->pCenter += TempVerts[i].Point; i++; // } } while (Parser->GetNextSymbol().LowerCase() != "endtri"); nv = i; tmp->Init(nv); tmp->pCenter /= (nv > 0 ? nv : 1); // memcpy(tmp->Vertices,TempVerts,nv*sizeof(TGroundVertex)); r = 0; for (int i = 0; i < nv; i++) { tmp->Vertices[i] = TempVerts[i]; tf = SquareMagnitude(tmp->Vertices[i].Point - tmp->pCenter); if (tf > r) r = tf; } // tmp->fSquareRadius= 2000*2000+r; tmp->fSquareRadius += r; }
//----------------------------------------------------------------------------- bool Vector3D::IsNormal() const { return (SquareMagnitude() == 1.0f); }
bool CFVec2::IsNormal( void ) const { return( fabsf(SquareMagnitude() - 1.0f) <= 0.0001f ); }
FLOAT32 CFVec2::Magnitude( void ) const { return sqrtf( SquareMagnitude() ); }