← Back to archive
Divination Theory

Modeling the Five Elements Using Angles

In a sense, the Five Elements relationship between two elements can be understood as an angular distance on a circle. Therefore, if two elements are known, the angle between them can in fact be computed. If the clockwise angle from A to B is between 0 and 72 degrees, then B and A are in a mutual (companion) relationship in the Five Elements; if it is between 72 and 144 degrees, A generates B. This way, the generating and overcoming cycles are simulated.

The difficulty here is how to codify this — computing the angle between two vectors. The Python code is as follows:

import numpy as np

def get_clockwise_rotation_angle(vector1, vector2):
    # Compute the dot product of the two vectors
    dot_product = np.dot(vector1, vector2)
    
    # Compute the norms (magnitudes) of the two vectors
    norm_vector1 = np.linalg.norm(vector1)
    norm_vector2 = np.linalg.norm(vector2)
    
    # Compute the cosine value
    cos_theta = dot_product / (norm_vector1 * norm_vector2)
    
    # Use the arccos function to compute the value in radians
    radians = np.arccos(cos_theta)
    
    # Convert radians to degrees
    degrees = np.degrees(radians)
    
    # Use the cross product to determine the direction of rotation
    cross_product = np.cross(vector1, vector2)
    
    # If the cross product is positive, adjust the angle to 360 - angle
    if cross_product > 0:
        degrees = 360 - degrees
    
    return degrees

Written by Master Sanfu on October 2, 2023. Please credit the source if you share.

Translation Notice: This English version was translated with AI assistance. Specialized, historical, religious, or culturally sensitive terms may contain nuances, inaccuracies, or debatable wording. In case of ambiguity or discrepancy, the original Chinese text shall prevail.