# -*- coding: UTF-8 -*-

# ============================================================================
# CC0 "No Rights Reserved"
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain 
# worldwide. See http://creativecommons.org/publicdomain/zero/1.0/.
# ============================================================================

# Skews nodes parallel to the specified axis and about the succeeding axis.
# Select nodes before using.

import math

axis = mw.input("Direction (x, y, z)").lower()
angle = float(mw.input(u"Angle (°)"))
ratio = math.tan(angle * math.pi/180)

for node_id in mw.selected_nodes():

    # Get the node's existing coordinates
    coordinates = mw.node(node_id)

    # Choose the axes
    if axis == "x":
        existing_coordinate = coordinates.x
        reference_coordinate = coordinates.z
        setter = mw.set_node_x
    if axis == "y":
        existing_coordinate = coordinates.y
        reference_coordinate = coordinates.x
        setter = mw.set_node_y
    if axis == "z":
        existing_coordinate = coordinates.z
        reference_coordinate = coordinates.y
        setter = mw.set_node_z
    
    # Change the node's coordinate.
    setter(node_id, existing_coordinate + ratio * reference_coordinate)
