Distance from Point to Line in 3D Calculator
Enter the point, a point on the line and the line's direction to get the distance.
Result
How it is calculated
The line is described by a point A = (ax, ay, az) on it and a direction vector D = (dx, dy, dz); the point you test is P = (px, py, pz). All nine numbers are needed, and coordinates share one length unit, so the distance comes out in that same unit (shown as generic units). The tool forms w = P − A, takes the cross product w × D, and returns distance = |w × D| ÷ |D|. It also shows |D| and |w × D| (the parallelogram area, in square units). D cannot be (0, 0, 0): a zero direction defines no line, so no result is shown. Results are given to four decimals.
Worked example
Let P = (3, 1, 4), A = (0, 0, 0) and D = (1, 2, 2). Then w = P − A = (3, 1, 4) and |D| = √(1 + 4 + 4) = 3. The cross product w × D = (1·2 − 4·2, 4·1 − 3·2, 3·2 − 1·1) = (−6, −2, 5), whose length is √(36 + 4 + 25) = √65 = 8.0623. Divide: 8.0623 ÷ 3 = 2.6874 units, which is the shortest distance from the point to the line.
Common mistakes
- Entering a second point on the line as the direction. D must be the difference between two points on the line (B − A), not B itself.
- Using a zero direction vector, for example when the two points picked on the line are the same point. No line is defined and nothing is calculated.
- Expecting the length of D to matter. Scaling D by 2 changes |D| and |w × D| but not the distance, which stays 2.6874 in the example.
- Treating the line as a segment. The line is infinite, so the distance can be smaller than the distance to the nearest end of a finite segment.
- Mixing units between coordinates (metres for P, centimetres for A). All nine values must use one unit.
Sources
- 2.5 Equations of Lines and Planes in Space (Theorem 2.12, Distance from a Point to a Line) — OpenStax, Calculus Volume 3
About this calculator
In three-dimensional space, the shortest distance from a point to a line is found with the vector formula |(P−A)×D| / |D|, where A is any known point on the line, D is its direction vector, and P is the point in question. The cross product (P−A)×D produces a vector whose magnitude equals the area of the parallelogram formed by the two vectors, and dividing by the length of D collapses that area into a perpendicular distance — a compact application of vector algebra that avoids needing to find the closest point explicitly.
This calculation is routine in computer graphics, robotics, and CAD/CAM software, where it's used for collision detection, ray-to-axis distance checks, camera and light positioning, and verifying tool paths against reference lines. Engineers and 3D programmers rely on it whenever a system needs to know how far an object sits from a defined trajectory or edge without computing a full nearest-point projection.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
Only the distance comes back, not the spot where the perpendicular lands. If you also need that closest point, take t = (P − A)·D / |D|², and the foot of the perpendicular is A + t·D. A handy self-check is to enter a point you know lies on the line, which should give 0.0000. Would the closest point itself be useful as an extra output?