Raised This Month: $32 Target: $400
 8% 

Calculating circular origin?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AdrenalinesWrath
Junior Member
Join Date: Aug 2017
Old 05-16-2022 , 18:56   Calculating circular origin?
Reply With Quote #1

hello everyone,

I'm trying to get origins around an origin to create a beam between center and the end of the circle
and I'm not really good at math lol.
for example origin would be {0.0,0.0,0.0} which would be the center, and the distance would be 150.0

so I want to make it start from the top of it, and make it go in circular motion by 360°

any snippet for it?

probably by using floatsin() and floatcos()? I have no idea how to use them

thanks in advance!


Figured it out! here's a lil snippet if anyone needs it:
PHP Code:
stock get_circular_origin(Float:angleFloat:origin[3], Float:radius,Float:COrigin[3])
{
       
COrigin[0] = radius floatcos(angle,degrees);
       
COrigin[1] = origin[1]
       
COrigin[2] = radius floatsin(angle,degrees);

__________________
"True Strength's keeping everything together, while everyone expects you to fall apart."

Last edited by AdrenalinesWrath; 05-16-2022 at 19:21.
AdrenalinesWrath is offline
XSlayer
Member
Join Date: Dec 2021
Old 05-17-2022 , 03:56   Re: Calculating circular origin?
Reply With Quote #2

Quote:
Originally Posted by AdrenalinesWrath View Post
hello everyone,

I'm trying to get origins around an origin to create a beam between center and the end of the circle
and I'm not really good at math lol.
for example origin would be {0.0,0.0,0.0} which would be the center, and the distance would be 150.0

so I want to make it start from the top of it, and make it go in circular motion by 360°

any snippet for it?

probably by using floatsin() and floatcos()? I have no idea how to use them

thanks in advance!


Figured it out! here's a lil snippet if anyone needs it:
PHP Code:
stock get_circular_origin(Float:angleFloat:origin[3], Float:radius,Float:COrigin[3])
{
       
COrigin[0] = radius floatcos(angle,degrees);
       
COrigin[1] = origin[1]
       
COrigin[2] = radius floatsin(angle,degrees);

This Can Help u

PHP Code:
new Float:g_vec[3] = {25.00.0, -20.0}
new 
Float:g_deg 0;

public 
fxWindFXClient )
{    
       
set_task(0.05"rotate"Client__"b"1);
 
       
set_task(1.0"fxRestore"Client__"b"1);
}
public 
fxRestoreClient )
{
        
g_vec[0] = 25.0;
        
g_vec[1] = 0.0;
        
g_vec[2] = -20.0;
}
public 
rotate(Client)
{
    new 
Float:xFloat:y
    x 
25*floatcos(g_degdegrees);
    
25*floatsin(g_degdegrees);
    
g_deg += 70;
    
    
display(Client)
    
    
g_vec[0] = x
    g_vec
[1] = y
    g_vec
[2] += 8.0;
}
public 
display(Client)
{
        new 
origin[3];

        
get_user_origin(Clientorigin)

        
message_begin(MSG_PVSSVC_TEMPENTITYorigin)
        
write_byte(TE_SPRITE// TE id
        
write_coord(floatround(g_vec[0] + origin[0]) )
        
write_coord(floatround(g_vec[1] + origin[1]) )
        
write_coord(floatround(g_vec[2] + origin[2]) )
        
write_shortengfuncEngFunc_ModelIndex"sprites/steam1.spr") );
        
write_byte(3// scale
        
write_byte(255// framerate
        
message_end() 

XSlayer is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-17-2022 , 08:16   Re: Calculating circular origin?
Reply With Quote #3

https://forums.alliedmods.net/showthread.php?t=336136

Use find_location_around_origin in the first post.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 05-17-2022 at 08:17.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
XSlayer
Member
Join Date: Dec 2021
Old 05-17-2022 , 18:55   Re: Calculating circular origin?
Reply With Quote #4

Quote:
Originally Posted by Natsheh View Post
https://forums.alliedmods.net/showthread.php?t=336136

Use find_location_around_origin in the first post.
totally unnecessary and poorly optimized for what he needs.
XSlayer is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-18-2022 , 06:17   Re: Calculating circular origin?
Reply With Quote #5

Quote:
Originally Posted by XSlayer View Post
totally unnecessary and poorly optimized for what he needs.
He didn't explain properly and its not poorly optimized, rather more competent, that isnt the thing he needed.

and FFS don't use grey color as the font color it makes it difficult to be read.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 05-18-2022 at 06:18.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
AdrenalinesWrath
Junior Member
Join Date: Aug 2017
Old 05-20-2022 , 08:39   Re: Calculating circular origin?
Reply With Quote #6

sorry for the late response everyone, thank you @XSlayer and @Natsheh for the help!

I used gray color cause I meant to show that I solved the problem.
what I was trying to do is create an entity that would rotate horizontally or vertically around the player and keeping it at the same direction even if the player turns around.

I ended up with these lines which did what I needed:

PHP Code:
static Float:VicOrigin[3], Float:EntOrigin[3]

    
pev(entpev_originEntOrigin)
    
pev(victimpev_originVicOrigin)
    
VicOrigin[0] = VicOrigin[0]+(200.0 floatcos(ang,degrees));
    
VicOrigin[2] = VicOrigin[2]+(200.0 floatsin(ang,degrees));
    
set_pev(ent,pev_origin,VicOrigin); 
and I used pev_origin for a reason instead of pev_velocity
__________________
"True Strength's keeping everything together, while everyone expects you to fall apart."
AdrenalinesWrath is offline
Reply


Thread Tools
Display Modes

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 07:02.


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