$SPAD/src/input dhtri.input

Timothy Daly December 3, 2016

Abstract

Contents

2

1 License

— license —

--Copyright The Numerical Algorithms Group Limited 1991.

———-

— * —

)set break resume
)spool dhtri.output
)set message test on
)set message auto off
)clear all

———-

Create Affine transformations (DH matrices) that transform a given triangle into another given triangle

tri2tri(t1, t2) returns a DHMATRIX which transforms t1 to t2, where t1 and t2 are the vertices of two triangles in 3-space.

— * —

--S 1 of 5
tri2tri(t1: List Point DoubleFloat, t2: List Point DoubleFloat): _
 DHMATRIX(DoubleFloat) ==
  n1 := triangleNormal(t1)
  n2 := triangleNormal(t2)
  tet2tet(concat(t1, n1), concat(t2, n2))
--R
--R   Function declaration tri2tri : (List(Point(DoubleFloat)),List(Point(
--R      DoubleFloat))) -> DenavitHartenbergMatrix(DoubleFloat) has been
--R      added to workspace.
--R                                                                   Type: Void
--E 1

———-

tet2tet(t1, t2) returns a DHMATRIX which transforms t1 to t2, where t1 and t2 are the vertices of two tetrahedrons in 3-space.

— * —

--S 2 of 5
tet2tet(t1: List Point DoubleFloat, t2: List Point DoubleFloat): _
 DHMATRIX(DoubleFloat) ==
  m1 := makeColumnMatrix t1
  m2 := makeColumnMatrix t2
  m2 * inverse(m1)
--R

--R   Function declaration tet2tet : (List(Point(DoubleFloat)),List(Point(
--R      DoubleFloat))) -> DenavitHartenbergMatrix(DoubleFloat) has been
--R      added to workspace.
--R                                                                   Type: Void
--E 2

———-

Put the vertices of a tetrahedron into matrix form — * —

--S 3 of 5
makeColumnMatrix(t) ==
  m := new(4,4,0)$DHMATRIX(DoubleFloat)
  for x in t for i in 1..repeat
    for j in 1..3 repeat
      m(j,i) := x.j
    m(4,i) := 1
  m
--R
--R                                                                   Type: Void
--E 3

———-

This returns a vector normal to the given triangle, whose length is the square root of the area of the triangle

— * —

--S 4 of 5
triangleNormal(t) ==
  a := triangleArea t
  p1 := t.2 - t.1
  p2 := t.3 - t.2
  c := cross(p1, p2)
  len := length(c)
  len = 0 => error "degenerate triangle!"
  c := (1/len)*c
  t.1 + sqrt(a) * c
--R
--R                                                                   Type: Void
--E 4

———-

This computes the are of a triangle using Heron’s formula — * —

--S 5 of 5
triangleArea t ==
  a := length(t.2 - t.1)

  b := length(t.3 - t.2)
  c := length(t.1 - t.3)
  s := (a+b+c)/2
  sqrt(s*(s-a)*(s-b)*(s-c))
--R
--R                                                                   Type: Void
--E 5
)spool
)lisp (bye)

———-

References^{[1] nothing}

6