# Intersection of ray and not quite helicoid?

I have a shape that I'm not sure what to call. Basically, given two line segments $$p$$ which lives on 3d points $$(a,b)$$, and $$q$$ which lives on 3d points $$(c,d)$$, the shape is defined by the surface created when creating line segments from every point starting from $$a$$->$$c$$ all the way to $$b$$->$$c$$, for every point between $$a$$ and $$b$$ on the line segment $$p$$.

What I need is a way to take a ray defined by $$origin + t * direction$$ or $$o + t*d$$ and find the intersection if it exists on the surface.

I'm not sure what this shape is called, it is sort of like a helicoid, but it has a different equation, it isn't defined by lateral lines with respect to $$p$$ like a helicoid is, and twisting the line segments completely around does not produce a 3d shape like a helicoid would, it produces a plane. I can't look up what the intersection would be because of this.

here is the type of shape and intersection I'm talking about:

(there would be no holes in the surface, the lines have spaces to illustrate where each line exists).

I know the set up for the equation must look something like:

$$o + t*d = EquationForSurface(p,q,(o + t*d))$$

but I'm not entirely sure what the other equation is. I know its an equation that spits out a different equation of a line segment depending on the location, but I don't know how to parameterize it.

I'm thinking I can rotate the point to make $$p$$ a line oriented on the origin laying flat, and considering that if you move a point along $$p$$ half way, the resulting line segment will end up half way on $$q$$, I can use that to take the x position of the transformed point to directly correspond to a point on $$p$$, and knowing the percentage along $$p$$, I'll also know the point on $$q$$, and then it is a simple test for point line-segment intersection.

so the equation for the surface should be something like (excluding bounds checking and edge cases):

def EquationForSurface(p:linesegment, q:linesegment, point:point3d):
#calculate the transformation matrix to orient p at 0,0 on middle to x,y plane.
transpx = calcorientxmat(p)
px = transform(p, transpx)
qx = transform(q, transpx)
pointx = transpx * point
px_percent = pointx.x / p.b.x + 0.5 #oriented at zero, so either side has side length
px_start = find_point_on_segment(px, px_percent)
qx_end = find_point_on_segment(qx, px_percent)
intersecting_line_segment = LineSegment(px_start, qx_end)

#orient line segment back to the origional space
reoriented_line_segment = transform(intersecting_line_segment, inv(transpx))
return equation_for_linesegment(reoriented_line_segment, point)


but having a hard time trying to bring this back into a parametric form I can solve for so I can figure out how to find the intersection with a ray.

The problem is that you over-complicate the problem. Let's start with your definition of the "surface". If you connect every point $$\vec p$$ on $$\vec{ab}$$ with every point $$\vec q$$ on $$\vec{cd}$$ you will not get a surface, but a volume (you have a tetrahedron). To see that, just connect $$\vec a$$ to $$\vec c$$ and $$\vec b$$ to $$\vec d$$.
Since you are talking about a surface, my guess that what you really want is to move a fraction $$f$$ of the way between $$\vec a$$ and $$\vec b$$ and connect with the point at the exact same fraction between $$\vec c$$ and $$\vec d$$. So that means $$\vec p=\vec a+(\vec b-\vec a)f\\\vec q=\vec c+(\vec d-\vec c)f$$Now write the equation connecting $$\vec p$$ and $$\vec q$$ as $$\vec i=\vec p+(\vec q-\vec p)g$$where $$g$$ is a parameter. Now all you need to do is to say that $$\vec i$$ is on the ray $$\vec o+\vec v t$$. I've used $$\vec v$$ here as not to confuse with the position vector of the $$d$$ point. Since you have three components, you have three equations. The unknowns are $$f$$, $$g$$, and $$t$$.
• But $\vec p=(p_x,p_y,p_z)$ and so on. You have three components. You can write the one vector equation as three scalar equations. Aug 9 '19 at 17:00