math - How can I detect if two polygons have the same shape? -
i check if 2 polygons (number of vectors unclear) have same shape. without rotations easy, how do rotated polygons? need know rotation angle, too.
boolean polygonshavesameshape(pvector[] polygon1, pvector[] polygon2){ … } float getrotationangle(pvector[] polygon1, pvector[] polygon2){ … }
with little number of vertices might worth checking distances between each vertex , others.
in square illustration dist(p1,p2), dist(p1,p3), dist(p1,p4), dist(p2,p3), dist(p2,p4) , dist(p3,p4). these values exist each polygon. there point has same distance set p1, , p2, , on.
once have vertex in 1 polygon distances connected same in sec polygon can utilize 1 of lines determine angle of rotation.
hope made sense.
math rotation geometry processing polygon
No comments:
Post a Comment