Raised This Month: $ Target: $400
 0% 

get_distance_f problem [ solved ]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 10-19-2014 , 12:33   Re: get_distance_f problem
Reply With Quote #3

PHP Code:
/***
*
*    Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*    
*    This product contains software technology licensed from Id 
*    Software, Inc. ("Id Technology").  Id Technology (c) 1996 Id Software, Inc. 
*    All Rights Reserved.
*
*   Use, distribution, and modification of this source code and/or resulting
*   object code is restricted to non-commercial enhancements to products from
*   Valve LLC.  All other use, distribution, or modification is prohibited
*   without written permission from Valve LLC.
*
****/
#ifndef VECTOR_H
#define VECTOR_H

//=========================================================
// 2DVector - used for many pathfinding and many other 
// operations that are treated as planar rather than 3d.
//=========================================================
class Vector2D
{
public:
    
inline Vector2D(void): x(0.0), y(0.0)                            { }
    
inline Vector2D(float Xfloat Y): x(0.0), y(0.0)                { XY; }
    
inline Vector2D operator+(const Vector2Dv)    const    { return Vector2D(x+v.xy+v.y);    }
    
inline Vector2D operator-(const Vector2Dv)    const    { return Vector2D(x-v.xy-v.y);    }
    
inline Vector2D operator*(float fl)                const    { return Vector2D(x*fly*fl);    }
    
inline Vector2D operator/(float fl)                const    { return Vector2D(x/fly/fl);    }
    
    
inline float Length(void)                        const    { return sqrt(x*y*);        }

    
inline Vector2D Normalize void ) const
    {
        
// Vector2D vec2;

        
float flLen Length();
        if ( 
flLen == )
        {
            return 
Vector2D0);
        }
        else
        {
            
flLen flLen;
            return 
Vector2DflLenflLen );
        }
    }

    
vec_t    xy;
};

inline float DotProduct(const Vector2Da, const Vector2Db) { return( a.x*b.a.y*b.); }
inline Vector2D operator*(float fl, const Vector2Dv)    { return fl; }

//=========================================================
// 3D Vector
//=========================================================
class Vector                        // same data-layout as engine's vec3_t,
{                                //        which is a vec_t[3]
public:
    
// Construction/destruction
    
inline Vector(void): x(0.0), y(0.0), z(0.0)                    { }
    
inline Vector(float Xfloat Yfloat Z): x(0.0), y(0.0), z(0.0)    { XYZ;                }
    
//inline Vector(double X, double Y, double Z)        { x = (float)X; y = (float)Y; z = (float)Z;    }
    //inline Vector(int X, int Y, int Z)                { x = (float)X; y = (float)Y; z = (float)Z;    }
    
inline Vector(const Vectorv): x(0.0), y(0.0), z(0.0)        { v.xv.yv.z;                } 
    
inline Vector(float rgfl[3]): x(0.0), y(0.0), z(0.0)        { rgfl[0]; rgfl[1]; rgfl[2];    }

    
// Operators
    
inline Vector operator-(void) const                { return Vector(-x,-y,-z);                }
    
inline int operator==(const Vectorv) const    { return x==v.&& y==v.&& z==v.z;    }
    
inline int operator!=(const Vectorv) const    { return !(*this==v);                    }
    
inline Vector operator+(const Vectorv) const    { return Vector(x+v.xy+v.yz+v.z);    }
    
inline Vector operator-(const Vectorv) const    { return Vector(x-v.xy-v.yz-v.z);    }
    
inline Vector operator*(float fl) const            { return Vector(x*fly*flz*fl);        }
    
inline Vector operator/(float fl) const            { return Vector(x/fly/flz/fl);        }
    
    
// Methods
    
inline void CopyToArray(floatrgfl) const        { rgfl[0] = xrgfl[1] = yrgfl[2] = z; }
    
inline float Length(void) const                    { return sqrt(x*y*z*z); }
    
operator float *()                                { return &x; } // Vectors will now automatically convert to float * when needed
    
operator const float *() const                    { return &x; } // Vectors will now automatically convert to float * when needed
    
inline Vector Normalize(void) const
    {
        
float flLen Length();
        if (
flLen == 0) return Vector(0,0,1); // ????
        
flLen flLen;
        return 
Vector(flLenflLenflLen);
    }

    
inline Vector2D Make2D void ) const
    {
        
Vector2D    Vec2;

        
Vec2.x;
        
Vec2.y;

        return 
Vec2;
    }
    
inline float Length2D(void) const                    { return sqrt(x*y*y); }

    
// Members
    
vec_t xyz;
};
inline Vector operator*(float fl, const Vectorv)    { return fl; }
inline float DotProduct(const Vectora, const Vectorb) { return(a.x*b.x+a.y*b.y+a.z*b.z); }
inline Vector CrossProduct(const Vectora, const Vectorb) { return Vectora.y*b.a.z*b.ya.z*b.a.x*b.za.x*b.a.y*b.); }



#endif 
PHP Code:
void Function(void) {
  
Vector2D mn;
  
float len = (n).Length();

Vector.h content, hope it helps.
Length2d request was made for AMX Mod X development build.
__________________

Last edited by claudiuhks; 10-21-2014 at 09:43.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:35.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode