Hey everyone,
I’ve been scouring the internet trying to find a way to find a point within a cone, considering i have a starting point, direction and radius but i have not had much luck. I want to try and find a point within say 25 degrees either side of the direction inside the cone. Any help would be greatly appreciated.
Thanks
Hi ,
Try to use this code
// Cone description
FVector cone_start(0.4, 0.6, 0.6); // cone apex
FVector cone_dir(0.4, 0.6, 0.3); // cone height
float r = 6; // base radius
// u, v, a - it is parameters to describe point in cone [0,1]
// u - parametrized cone point height
// v - parametrized cone point radius
// a - parametrized angle, describe cone base vector direction
float u = 0.1, v = 0.6, a = 0.5;
// Get vectors perpendicular to cone direction, for 2d coordinate system in cone base
FVector axis1, axis2;
cone_dir.FindBestAxisVectors(axis1, axis2);
// get 2d direction in cone base
float angle = 2 * PI * a; // convert parametrized angle to [0;2*pi] region
FVector2D base_dir(sin(angle), cos(angle)); // rotate 2d vector (1,0)
base_dir *= u*v*r; // calculate base vector radius
// calculate point in cone
FVector cone_point = cone_start + cone_dir * u + axis1*base_dir.X + axis2*base_dir.Y;
Hope it helps!
Sorry for the delayed reply! Thank you it was very helpful