Tue Nov 02, 2021 3:48 pm

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?

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?

Wed Nov 03, 2021 1:39 am

You use the length function for vectors like this:

- Code:
`Vector2 SomeVector = (X, Y);`

Double SomeRadius = SomeVector.Length();

Wed Nov 03, 2021 3:40 am

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.

Wed Nov 03, 2021 11:53 am

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

- Code:
`Vector2 SomeVector = (X, Y);`

Double SomeRadius = SomeVector.Length();

This worked like a charm! Thank you