Changeset 2710


Ignore:
Timestamp:
Apr 12, 2006, 3:07:18 PM (18 years ago)
Author:
ole
Message:

Cleaned up in angle computation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/utilities/numerical_tools.py

    r2709 r2710  
    4141    # Compute angle
    4242    p = innerproduct(v1, v2)
    43     c = crossproduct_length(v1, v2)
     43    c = innerproduct(v1, normal_vector(v2)) # Projection onto normal
     44                                            # (negative cross product)
    4445   
    4546    theta = acos(p)
     
    4849    # If v2 was the unit vector [1,0] this would correspond to the test
    4950    # if v1[1] < 0: theta = 2*pi-theta   
    50     # In general we use the sign of the cross product length
    51     if c > 0:
     51    # In general we use the sign of the projection onto the normal.
     52    if c < 0:
    5253       #Quadrant 3 or 4
    5354       theta = 2*pi-theta       
     
    8283
    8384   
    84 def crossproduct_length(v1, v2):
    85     return v1[0]*v2[1]-v2[0]*v1[1]
     85#def crossproduct_length(v1, v2):
     86#    return v1[0]*v2[1]-v2[0]*v1[1]
    8687   
    8788       
Note: See TracChangeset for help on using the changeset viewer.