File: Line3.cpp

package info (click to toggle)
imath 3.1.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,468 kB
  • sloc: cpp: 44,687; ansic: 171; sh: 153; python: 60; makefile: 32
file content (23 lines) | stat: -rw-r--r-- 569 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <Imath/ImathLine.h>
#include <cassert>

void
line3_example()
{
    Imath::V3f   a (0.0f, 0.0f, 0.0f);
    Imath::V3f   b (1.0f, 1.0f, 1.0f);

    Imath::Line3f line (a, b);
  
    assert (line.pos == a);
    assert (line.dir == (b-a).normalized());
    
    Imath::V3f   c (0.5f, 0.5f, 0.5f);

    float f = line.distanceTo (c);
    assert (Imath::equalWithAbsError (f, 0.0f, 0.0001f));

    Imath::V3f p = line (0.5f); // midpoint, i.e. 0.5 units from a along (b-a)

    assert (p.equalWithAbsError (Imath::V3f (0.288675f, 0.288675f, 0.288675f), 0.0001f));
}