I'm new to C++ and am more used to Python. I have found posts answering this question, but I haven't been able to modify what I've found to work in my code. The goal of my function is simple, I want it to give me an array with x, y, and z coordinates where I give it polar coordinates. Here's what I have that isn't working:
double coordinate_finder(double coordinates[], double radius)
{
double x = radius * sin(radians(90 - coordinates[0])) * cos(radians(coordinates[1]));
double y = radius * sin(radians(90 - coordinates[0])) * sin(radians(coordinates[1]));
double z = radius * cos(radians(90 - coordinates[0]));
double XYZ[] = { x,y,z };
return XYZ;
}
I feel like what I want it to do reads pretty easily but I'd like it to return XYZ when the function is called later in the code. By the way radians() is a function I made which converts degrees to radians.
std::arrayorstd::vectorinstead.pointstruct with x, y, and z members :/coordinatesif you want. But make sure to make internal copies if necessary.