# Forum

### Author Topic: Implement shim for PointCloud.pickPoint for 1.2.6?  (Read 137 times)

#### akoumis

• Newbie
• Posts: 3
##### Implement shim for PointCloud.pickPoint for 1.2.6?
« on: July 17, 2018, 12:15:55 AM »
Hello, I am working in an environment where we cannot upgrade our PhotoScan version beyond 1.2.6. I tested a script that uses PointCloud.pickPoint successfully with a newer version (1.4.2) and would like to develop a version of pickPoint() that is compatible with 1.2.6. Does anyone have an implementation of pickPoint() they have created that they can share?

Thank you!

#### akoumis

• Newbie
• Posts: 3
##### Re: Implement shim for PointCloud.pickPoint for 1.2.6?
« Reply #1 on: July 19, 2018, 12:22:29 AM »
Please ignore this for now, I believe I have implemented a similar method based on this formula: http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html, here is my code:

Code: [Select]
`def _pick_point(points, cam_center, cam_direction):    min_dist = float('inf')    min_point = None    x1 = cam_center    x2 = cam_center + cam_direction    for point in points:        x0 = PhotoScan.Vector([point.coord[0], point.coord[1], point.coord[2]])        numerator = (PhotoScan.Vector.cross(x0 - x1, x0 - x2)).norm()        denominator = (x2 - x1).norm()        distance = numerator / denominator        if distance < min_dist:            min_dist = distance            min_point = point    return min_point`