0
$\begingroup$

If I have a line in 3d like $(x,y,z)+t(a,b,c)$, and 3 constraints

$x_{min} ≤ x_0 ≤ x_{max}$

$y_{min} ≤ y_0 ≤ y_{max}$

$z_{min} ≤ z_0 ≤ z_{max}$

Given $x_{min}, x_{max}, y_{min}, y_{max}, z_{min}, z_{max}, (x,y,z), (a,b,c)$, how can I check if there exists a point $(x_0,y_0,z_0)$ in the line that also satisfies the 3 constraints above?

Thanks

1 Answers 1

1

Each coordinate will give a constraint on $t$. So we have

$$x_{min} \leq x + at \leq x_{max}$$

so this requires

$$ \frac{x_{min}-x}{a} \leq t \leq \frac{x_{max}-x}{a}$$

and similarly

$$ \frac{y_{min}-y}{b} \leq t \leq \frac{y_{max}-y}{b}$$

$$ \frac{z_{min}-z}{c} \leq t \leq \frac{z_{max}-z}{c}$$

and there's a solution if all those three intervals have a non empty intersection.

  • 0
    What if a=0 or b=0 or c=0? And is there a way to actually solve the solution?2017-02-08
  • 0
    @omega If a = 0, then the x-axis doesn't play a role in finding a nonempty intersection (the line is constant in the x-axis). Hence, any tx is valid as long as x is within bounds. Similar statements can be made for tb when b = 0 and tc when c = 0. When all three variables are 0, all t are valid as long as (x, y, z) is within bounds.2018-05-22