Skip to content

Intersection of a Line and a Sphere - MAXScript function

by Royal Ghost·Workflow

Illustrative cover generated by AnyPlugins — no product screenshot available.

Why we like it

A direct MAXScript port of Paul Bourke's documented line-sphere intersection routine, it earns its place for scripters who need this specific geometry calculation available inside 3ds Max.

What is Intersection of a Line and a Sphere - MAXScript function?

Intersection of a Line and a Sphere is a MAXScript function for 3ds Max, developed by Royal Ghost. It is a MAXScript version of the function "Intersection of a Line and a Sphere (or circle)" written by Paul Bourke.

The function classifies the relationship between a line and a sphere using a discriminant. A value below 0 means the line does not intersect the sphere, a value of 0 means the line is tangent and meets the sphere at one point (u = -b/2a), and a value above 0 means the line intersects the sphere at two points. For line segments, the u parameters describe the case: both u values below 0 or above 1 indicate a segment outside the sphere, while one negative u and one above 1 indicate a segment inside it.

Its underlying math also carries conditions on the input points. No three combinations of the four points can be collinear, and all four points cannot be coplanar. The denominator (mb - ma) is zero only when the lines are parallel and coincident, in which case no circle results. The developer's link points to Paul Bourke's original geometry page.

Who is Intersection of a Line and a Sphere - MAXScript function best for?

Intersection of a Line and a Sphere - MAXScript function is best for 3ds Max users writing MAXScript who need to compute where a line intersects a sphere or circle.

How much does Intersection of a Line and a Sphere - MAXScript function cost?

Intersection of a Line and a Sphere - MAXScript function is completely free to download and use.

Key features

  • A discriminant below 0 means the line does not intersect the sphere
  • A discriminant of 0 means the line is tangent, meeting the sphere at one point (u = -b/2a)
  • A discriminant above 0 means the line intersects the sphere at two points
  • For a segment outside the sphere, both u values fall below 0 or above 1
  • For a segment inside the sphere, one u value is negative and the other is above 1
  • The denominator (mb - ma) is zero only when the lines are parallel and coincident, yielding no circle
  • Requires that no three of the four points be collinear and that the four points not be coplanar

Tags

#MAXScript#3ds Max#geometry#line-sphere intersection#scripting#math function#Paul Bourke

Frequently asked questions

How does Intersection of a Line and a Sphere determine whether a line hits the sphere?

Intersection of a Line and a Sphere works from a discriminant value that classifies the geometry. When that value is less than 0, the line does not intersect the sphere. When it equals 0, the line is tangent and touches the sphere at a single point, at u = -b/2a. When it is greater than 0, the line intersects the sphere at two points. This three-way test gives a clear signal about the relationship between the line and the sphere before you use the resulting intersection parameters in your script.

Can Intersection of a Line and a Sphere handle line segments that don't reach the sphere?

Intersection of a Line and a Sphere accounts for line segments as well, using the u parameters to describe where a segment sits relative to the sphere. When a segment lies outside the sphere without intersecting, both u values fall below 0 or above 1. When a segment sits inside the sphere without intersecting its surface, one u value is negative and the other is greater than 1. Reading these parameter ranges lets you distinguish the segment cases from a true intersection.

What point conditions does Intersection of a Line and a Sphere require?

Intersection of a Line and a Sphere carries conditions tied to its underlying math. No three combinations of the four points can be collinear, and all four points cannot lie on the same plane, meaning they must not be coplanar. There is also a denominator, (mb - ma), that is zero only when the lines are parallel, in which case they are coincident and no circle results. Keeping input points within these constraints avoids the degenerate cases the function cannot resolve.

What version of Intersection of a Line and a Sphere is available?

Intersection of a Line and a Sphere is listed at version 1.0.0. It is a MAXScript version of the function "Intersection of a Line and a Sphere (or circle)" written by Paul Bourke, adapted for use inside 3ds Max. For the original geometry write-up and further details, the developer's link points to Paul Bourke's site on circles and spheres, which is the best place to review the underlying math behind the routine.

Similar plugins