# Difference between revisions of "VTK/Examples/Python/DistanceBetweenPoints"

From KitwarePublic

Jump to navigationJump to searchm (Missing file name) |
|||

Line 1: | Line 1: | ||

==DistanceBetweenPoints.py== | ==DistanceBetweenPoints.py== | ||

<source lang="python"> | <source lang="python"> | ||

+ | from __future__ import print_function | ||

import vtk | import vtk | ||

import math | import math | ||

Line 11: | Line 12: | ||

dist = math.sqrt(distSquared) | dist = math.sqrt(distSquared) | ||

− | print "p0 = ", p0 | + | print("p0 = ", p0) |

− | print "p1 = ", p1 | + | print("p1 = ", p1) |

− | print "distance squared = ", distSquared | + | print("distance squared = ", distSquared) |

− | print "distance = ", dist | + | print("distance = ", dist) |

+ | |||

</source> | </source> |

## Latest revision as of 01:49, 22 August 2015

## DistanceBetweenPoints.py

```
from __future__ import print_function
import vtk
import math
p0 = (0,0,0)
p1 = (1,1,1)
distSquared = vtk.vtkMath.Distance2BetweenPoints(p0,p1)
dist = math.sqrt(distSquared)
print("p0 = ", p0)
print("p1 = ", p1)
print("distance squared = ", distSquared)
print("distance = ", dist)
```