JNR
laLine3 Class Reference

3D line segment More...

`#include <laLine3.h>`

## Public Member Functions

laLine3 (laPoint3 &a, laPoint3 &b)

laPoint3 intersection (laLine3 &l, double &pk1)
Find point of intersection (or nearest point) to another laLine3. More...

laPoint3 intersection (class laPlane3 &pn, double *pk=NULL)
Find point of intersection with laPlane3.

void draw (class laRenderer *r, laPoint3 pos)
Draw the line ( primarily for debug purposes )

Line constructors and initialization methods
void build_2pt (laPoint3 &a, laPoint3 &b)
Build from two end-points.

void build_vec (laPoint3 &a, laPoint3 &v)
Build from an end-poind and vector.

Lenght of the segment
double lenght () const

double lenght_sq () const
Squared root of segment lenght.

Getting points at different positions on the line
laPoint3 end () const
Get endpoint.

void at (double k, laPoint3 *ppt) const
Get point at 1/k lenght (returns in user-specified pointer) More...

laPoint3 at (double k) const

## Public Attributes

laPoint3 origin
Point of origin.

laPoint3 vector
Vector ( not normalized, so k = [0;1] traces the whole line segment )

## Detailed Description

3D line segment

Definition at line 40 of file laLine3.h.

## Member Function Documentation

 void laLine3::at ( double k, laPoint3 * ppt ) const
inline

Get point at 1/k lenght (returns in user-specified pointer)

Get point at 1/k lenght (retruns a new object)

Definition at line 85 of file laLine3.h.

Referenced by intersection().

 laPoint3 laLine3::intersection ( laLine3 & l, double & pk1 )

Find point of intersection (or nearest point) to another laLine3.

= is not a good idea for double vars

Definition at line 48 of file laLine3.cpp.

49 {
50  double k1;
51  double btm;
52
53  //yz
54  btm = vector.z()*l.vector.y() - vector.y()*l.vector.z();
55  if((btm)!=0){
56  k1 = -( vector.y()*origin.z() + vector.z()*l.origin.y() - vector.z()*origin.y() - vector.y()*l.origin.z() )/
57  ( btm );
58  pk1 = k1;
59
60  laPoint3 pt; l.at(k1, &pt);
61  return pt;
62  }
63
64  //xz
65  btm = vector.z()*l.vector.x() - vector.x()*l.vector.z();
66  if((btm)!=0){
67  k1 = -( vector.x()*origin.z() + vector.z()*l.origin.x() - vector.z()*origin.x() - vector.x()*l.origin.z() )/
68  ( btm );
69  pk1 = k1;
70
71  laPoint3 pt; l.at(k1, &pt);
72  return pt;
73  }
74
75  //xy;
76  btm = vector.y()*l.vector.x() - vector.x()*l.vector.y();
77  if((btm)!=0){
78  k1 = -( vector.x()*origin.y() + vector.y()*l.origin.x() - vector.y()*origin.x() - vector.x()*l.origin.y() )/
79  ( btm );
80  pk1 = k1;
81
82  laPoint3 pt; l.at(k1, &pt);
83  return pt;
84  }
85
86  k1 = 999; //wtf??
87  pk1 = k1;
88
89  laPoint3 pt; l.at(k1, &pt);
90  return pt;
91 }
laPoint3 vector
Vector ( not normalized, so k = [0;1] traces the whole line segment )
Definition: laLine3.h:44
laPoint3 origin
Point of origin.
Definition: laLine3.h:43
void at(double k, laPoint3 *ppt) const
Get point at 1/k lenght (returns in user-specified pointer)
Definition: laLine3.h:85

The documentation for this class was generated from the following files: