Just for a laugh I tried this in JRubyArt:-
attr_reader :aaa, :abb
def settings
size(300, 300)
end
def setup
sketch_title "Average Heading"
@aaa = 225
@abb = 135
end
def draw
background(200)
stroke(0)
noFill
circle(width / 2, height / 2, width)
push_matrix
translate(width / 2, height / 2)
vector_a = Vec2D.from_angle(aaa.radians)
vector_b = Vec2D.from_angle(abb.radians)
stroke(255, 0, 0)
line(0, 0, vector_a.x * 150, vector_a.y * 150)
line(0, 0, vector_b.x * 150, vector_b.y * 150)
averageHeading = ((vector_a + vector_b) / 2.0).heading
vector_c = Vec2D.from_angle(averageHeading)
vector_c.set_mag(150)
stroke(255, 0, 255)
line(0, 0, vector_c.x, vector_c.y)
pop_matrix
end
Works with 45 and -45 degrees gets:-