| 916 | } |
| 917 | |
| 918 | void test_point_circle_distance() |
| 919 | { |
| 920 | const geode::Point3D a{ { 0.0, 0.0, 1.0 } }; |
| 921 | const geode::Vector3D normal_x{ { -1.0, 0.0, 0.0 } }; |
| 922 | const geode::Vector3D normal_z{ { 0.0, 0.0, 1.0 } }; |
| 923 | const geode::Plane plane_x{ normal_x, a }; |
| 924 | const geode::Plane plane_z{ normal_z, a }; |
| 925 | const geode::Circle circle_x{ plane_x, 2 }; |
| 926 | const geode::Circle circle_z{ plane_z, 2 }; |
| 927 | |
| 928 | double distance; |
| 929 | geode::Point3D closest_point, answer; |
| 930 | |
| 931 | const geode::Point3D q1{ { 2.0, 0.0, 1.0 } }; |
| 932 | std::tie( distance, closest_point ) = |
| 933 | geode::point_circle_distance( q1, circle_x ); |
| 934 | answer = geode::Point3D{ { 0.0, 2.0, 1.0 } }; |
| 935 | geode::OpenGeodeGeometryException::test( |
| 936 | distance == sqrt( 8 ) && closest_point.inexact_equal( answer ), |
| 937 | "Wrong result for point_circle_distance with query Point3D " |
| 938 | "q1 and circle_x" ); |
| 939 | |
| 940 | std::tie( distance, closest_point ) = |
| 941 | geode::point_circle_distance( q1, circle_z ); |
| 942 | geode::OpenGeodeGeometryException::test( |
| 943 | distance == 0 && closest_point.inexact_equal( q1 ), |
| 944 | "Wrong result for point_circle_distance with query Point3D " |
| 945 | "q1 and circle_z" ); |
| 946 | |
| 947 | std::tie( distance, closest_point ) = |
| 948 | geode::point_circle_signed_distance( q1, circle_x ); |
| 949 | answer = geode::Point3D{ { 0.0, 2.0, 1.0 } }; |
| 950 | geode::OpenGeodeGeometryException::test( |
| 951 | distance == -sqrt( 8 ) && closest_point.inexact_equal( answer ), |
| 952 | "Wrong result for point_circle_signed_distance with query " |
| 953 | "Point3D " |
| 954 | "q1 and circle_x" ); |
| 955 | |
| 956 | std::tie( distance, closest_point ) = |
| 957 | geode::point_circle_signed_distance( q1, circle_z ); |
| 958 | geode::OpenGeodeGeometryException::test( |
| 959 | distance == 0 && closest_point.inexact_equal( q1 ), |
| 960 | "Wrong result for point_circle_signed_distance with query " |
| 961 | "Point3D " |
| 962 | "q1 and circle_z" ); |
| 963 | |
| 964 | std::tie( distance, closest_point ) = |
| 965 | geode::point_disk_distance( q1, circle_x ); |
| 966 | answer = geode::Point3D{ { 0.0, 0.0, 1.0 } }; |
| 967 | geode::OpenGeodeGeometryException::test( |
| 968 | distance == 2 && closest_point.inexact_equal( answer ), |
| 969 | "Wrong result for point_disk_distance with query Point3D " |
| 970 | "q1 and circle_x" ); |
| 971 | |
| 972 | std::tie( distance, closest_point ) = |
| 973 | geode::point_disk_distance( q1, circle_z ); |
| 974 | geode::OpenGeodeGeometryException::test( |
| 975 | distance == 0 && closest_point.inexact_equal( q1 ), |
no test coverage detected