I've run into a problem that's kicking my ass.
The provided variables are the cone angle(cA) of a cone that starts at the origin along the Z axis, the vertical angle (vA) of the direction the cone is facing, and a horizontal angle (hA) along with a distance (d) along that angle to reach the xy plane.
With this information I need to find the coordinates on the XY plane where the cone intersects a vertical line generated using the provided horizontal angle and distance. The X is easy to find using Sin(hA) * d.
The cone itself is always originates directly on the Z axis pointing towards the XY plane with a varying vertical angle (vA). Using the cone angle to project what would probably be an ellipses onto the XY plane, I'm looking for the formula used to derive the Y coordinate/s that intersect the vertical line on the X coordinate.
Solution
So, here's what we think is currently the solution.
Provided variables.
hA : horizontal angle
vA : vertical angle
cA : cone angle
d : distance along angle
Necessary variables
x : the length of the line that connects the (0,0) point on the XY plane to the dotted line. Derived by using hA and distance.
x= Sin(hA) * d
z : distance from the origin to (0,0) on the XY plane. Derived by using hA and distance.
z = Cos(hA) *d
cTA : angle from origin to top cone wall. Knowing the angle of the cone's vertex and also knowing that it will be pointing at a point along the y-axis we can determine that subtracting the vertical angle from the cone's angle will give us the angle from the origin to the y coordinate that will be intersected by the cone's wall.
cTA = cA - vA
dYTop: Point on y-axis that is intersected by the top of the cone's wall. Derived by using cTA and z.
dYTop = Tan(cTA) * z
yMid: distance from (0,0) to the cone axis intercept along the y-axis. derived by using vA and z.
yMid = Tan(vA) * z
c: distance from origin to yMid. pythagorean theorem.
c = sqrt(yMid^2 + z^2)
hRadius: horizontal radius of the cone. Derived using cA and c
Tan(cA) * c
vRadius: vertical radius of the cone. Derived by subtracting yMid from dYTop
vRadius = dYTop - yMid
After that we have all the variables needed to input into this formula.
x^2 / hRadius^2 + (y - yMid)^2 / vRadius^2) = 1
Solve for y to get the y points.
height1 = (int)(Math.Sqrt(1 - (x * x) / (hRadius * hRadius)) * vRaduis + yMid);
height2 = (int)(yMid - Math.Sqrt(1 - (x * x) / (hRadius * hRadius)) * vRaduis);
The image above would not have any solutions as the cone's angle isn't large enough to intercept the dotted line at x. I haven't started actually testing this yet but it looks right.... big thanks to @heavyduty32 !
Log in to comment