summaryrefslogtreecommitdiff
path: root/ipl/procs/ptutils.icn
blob: 18f4e738cab9dbae3e5565c416a3d997b3a56224 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
############################################################################
#
#	File:     ptutils.icn
#
#	Subject:  Procedures relating to objects in 3-space
#
#	Author:   Ralph E. Griswold
#
#	Date:     March 25, 2002
#
############################################################################
#
#  This file is in the public domain.
#
############################################################################
#
#  These procedures provide various operations on 3-dimensional objects
#  in 3-space.
#
############################################################################
#
#  Links:  gobject
#
############################################################################

link gobject

procedure pt2coord(p)			#: convert point to coordinate

   return p.x || " " || p.y || " " || p.z

end

procedure coord2pt(c)			#: convert coordinate to path
   local p

   p := Point()

   c ? {
      p.x := tab(upto(' '))
      move(1)
      p.y := tab(upto(' '))
      move(1)
      p.z := tab(0)
      }

   return p

end

procedure negpt(p)			#: negative of point

    return Point(-p.x, -p.y, -p.z)

end

procedure pteq(p1, p2)			#: test point equality

   if p1.x = p2.x & p1.y = p2.y & p1.z = p2.z then return p2 else fail

end

procedure getpts(s)			#: make point list from coordinate file
   local input, pts

   input := open(s) | stop("*** cannot open ", image(s))

   pts := []

   while put(pts, coord2pt(read(input)))

   return pts

end