Senior Member
Join Date: Apr 2017
Location: Portugal
09-30-2019
, 15:55
Re: How to create circle
#21
Quote:
Originally Posted by
Natsheh
i'm not worried about getting the player in the circle right now but more about drawing the circle.
actually i want to be able to rotate the circle with given inputs...
so i want to be able to create a circle around a vector
i almost done it but remains one thing rotating the vector around the main vector to create a circle point by point.
my goal is to create a circle in vector plane and not just in XY and ZY nor ZX axis's plane...
my latest update.
Spoiler
PHP Code:
public brain_work ( id )
{
static Float : fAngles [ 3 ], Float : fRadius [ 3 ], Float : fOrigin [ 3 ], Float : fTemp [ 3 ], Float : fPos [ 3 ], i ;
pev ( id , pev_angles , fAngles );
pev ( id , pev_origin , fOrigin )
pev ( id , pev_fuser4 , fRadius [ Y ]);
fRadius [ X ] = 0.0 ;
fRadius [ Z ] = 0.0 ;
static Float : fCosY , Float : fSinY , Float : fCosX , Float : fSinX ;
fCosY = floatcos ( fAngles [ Y ], degrees );
fSinY = floatsin ( fAngles [ Y ], degrees );
fCosX = floatcos ( fAngles [ X ], degrees );
fSinX = floatsin ( fAngles [ X ], degrees );
fPos [ X ] = fCosY * fRadius [ X ] - fSinY * fRadius [ Y ];
fPos [ Y ] = fCosX * fSinY * fRadius [ X ] + fCosX * fCosY * fRadius [ Y ] - fSinX * fRadius [ Z ]
fPos [ Z ] = fSinX * fSinY * fRadius [ X ] + fSinX * fCosY * fRadius [ Y ] + fCosX * fRadius [ Z ];
xs_vec_add ( fPos , fOrigin , fTemp );
createline ( fOrigin , fTemp , 255 , 0 , 0 )
const Float : fDivides = 30.0 ;
static Float : fAngle [ 3 ], Float : fVector [ 3 ] = { 0.0 , 0.0 , 0.0 }, Float : fStart [ 3 ];
xs_vec_copy ( fAngles , fAngle );
angle_vector ( fAngle , ANGLEVECTOR_RIGHT , fTemp );
vector_to_angle ( fTemp , fAngle );
xs_vec_mul_scalar ( fTemp , 50.0 , fTemp );
for( i = 0 ; i <= floatround ( 360.0 / fDivides ); i ++)
{
if( i > 0 )
{
xs_vec_copy ( fVector , fStart );
}
///// here im calculating the vector after it has been moved to the right of the main vector
fCosY = floatcos ( fAngle [ Y ], degrees );
fSinY = floatsin ( fAngle [ Y ], degrees );
fCosX = floatcos ( fAngle [ X ], degrees );
fSinX = floatsin ( fAngle [ X ], degrees );
fPos [ X ] = fCosY * fTemp [ X ] - fSinY * fTemp [ Y ];
fPos [ Y ] = fCosX * fSinY * fTemp [ X ] + fCosX * fCosY * fTemp [ Y ] - fSinX * fTemp [ Z ]
fPos [ Z ] = fSinX * fSinY * fTemp [ X ] + fSinX * fCosY * fTemp [ Y ] + fCosX * fTemp [ Z ];
client_print ( 0 , print_chat , "fPos X: %.4f fPos Y: %.4f fPos Z: %.4f" , fPos [ X ], fPos [ Y ], fPos [ Z ]);
xs_vec_add ( fOrigin , fPos , fVector );
createline ( fOrigin , fVector , 255 , 255 , 0 )
/// below this 100% wrong or not accurate this suppose to increase the next vector angle by 30 degrees around the main vector...
fAngle [ X ] += fDivides * ( floatsin ( fAngles [ Y ], degrees ) + floatcos ( fAngles [ X ], degrees ));
fAngle [ Y ] += fDivides * ( floatcos ( fAngles [ X ], degrees ) - floatcos ( fAngles [ Y ], degrees ));
if( i > 0 )
{
createline ( fStart , fVector );
}
}
entity_set_float ( id , EV_FL_nextthink , get_gametime () + 1.0 );
}
I understand that you want to create a circle that you can rotate by the X, Y and Z axis, but unfortunately I'm not used to use vectors and stuff like that, so the best thing I can do to help is the code for checking if the player is inside the circle (although any possible way to check it is to create a "box" where the limits are the circle's limits).