<commit_before>"""Python script to compute the exterior orientation for a NADIR image
that views a specified ground point with North up.

This script requires the following packages: numpy, pandas, quaternion, numba
"""


import numpy as np
import pandas as pd
import quaternion, argparse, os, subprocess

def compute_position(ground_point, distance):
    bf_position = np.array(distance / np.linalg.norm(ground_point)) * ground_point
    return bf_position

def rotation_between(u, v, fallback=None):
    tolerance=1e-10

    unit_u = u / np.linalg.norm(u)
    unit_v = v / np.linalg.norm(v)

    dot = np.dot(unit_u,unit_v)
    # If the vectors are within tolerance of parallel, return identity rotation
    if dot >  1.0 - tolerance:
        return np.quaternion(1,0,0,0)
    # If the vectors are within tolerance of opposite, return a 180 degree rotation
    # about an arbitrary perpendicular axis.
    # If no fall back axis is provided,
    # try the cross product of the x-axis and u.
    # If they are co-linear use the y-axis.
    elif dot < -1.0 + tolerance:
        if fallback is None:
            axis = fallback<commit_msg>Fixed error with polar looks in perspective script.<commit_after>"""Python script to compute the exterior orientation for a NADIR image
that views a specified ground point with North up.

This script requires the following packages: numpy, pandas, quaternion, numba
"""


import numpy as np
import pandas as pd
import quaternion, argparse, os, subprocess

def compute_position(ground_point, distance):
    bf_position = np.array(distance / np.linalg.norm(ground_point)) * ground_point
    return bf_position

def rotation_between(u, v, fallback=None):
    tolerance = 1e-10

    if np.linalg.norm(u) < tolerance or np.linalg.norm(v) < tolerance:
        return np.quaternion(1,0,0,0)

    unit_u = u / np.linalg.norm(u)
    unit_v = v / np.linalg.norm(v)

    dot = np.dot(unit_u,unit_v)
    # If the vectors are within tolerance of parallel, return identity rotation
    if dot >  1.0 - tolerance:
        return np.quaternion(1,0,0,0)
    # If the vectors are within tolerance of opposite, return a 180 degree rotation
    # about an arbitrary perpendicular axis.
    # If no fall back axis is provided,
    # try the cross product of the x-axis and u.
    # If they are co-linear use the y-axis.
    elif dot < -1.0 + tolerance:
        if fallback is not None:
            axis = fallback
{'fraction_non_alphanumeric': 0.07983539094650206, 'fraction_numerical': 0.01316872427983539, 'mean_word_length': 3.220486111111111, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1544581', 'n_tokens_mistral': 761, 'n_tokens_neox': 728, 'n_words': 282}