Radius Calculation in Security Camera Class Issue

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Immorpher
Posts: 11
Joined: Sun Jun 02, 2019 9:34 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Radius Calculation in Security Camera Class Issue

Post by Immorpher »

I am trying to calculate the radius of two offsets in a zscript security camera class using:
double radius = sqrt(x*x + y*y);

But I get the error "Sqrt is not a member function...". So it seems I am using the wrong function. I also found a VectorLength function but that gave a similar error. Perhaps I should be doing this a different way?
User avatar
22alpha22
Posts: 303
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

Re: Radius Calculation in Security Camera Class Issue

Post by 22alpha22 »

You use the length function for vectors like this:

Code: Select all

Vector2 SomeVector = (X, Y);
Double SomeRadius = SomeVector.Length();
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Radius Calculation in Security Camera Class Issue

Post by Graf Zahl »

You need to give us some context about where you placed that code. THat fragment is not nearly enough to give an answer. Post the entire function/class.
User avatar
Immorpher
Posts: 11
Joined: Sun Jun 02, 2019 9:34 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Radius Calculation in Security Camera Class Issue

Post by Immorpher »

22alpha22 wrote:You use the length function for vectors like this:

Code: Select all

Vector2 SomeVector = (X, Y);
Double SomeRadius = SomeVector.Length();
This worked like a charm! Thank you :D
Post Reply

Return to “Scripting”