<commit_before>{- This Source Code Form is subject to the terms of the Mozilla Public License,
   v. 2.0. If a copy of the MPL was not distributed with this file, you can
   obtain one at http://mozilla.org/MPL/2.0/.

   Copyright 2016 by <NAME>
   <EMAIL>
-}


module Point3d exposing (suite)

import Test exposing (Test)
import Test.Runner.Html as Html
import OpenSolid.Point3d as Point3d
import OpenSolid.Core.Encode as Encode
import OpenSolid.Core.Decode as Decode
import OpenSolid.Core.Fuzz as Fuzz
import OpenSolid.Core.Expect as Expect
import Generic


rotationAboutAxisPreservesDistance : Test
rotationAboutAxisPreservesDistance =
    let
        description =
            "Rotation about axis preserves distance along that axis"

        expectation point axis angle =
            let
                distance =
                    Point3d.signedDistanceAlong axis point

                rotatedPoint =
                    Point3d.rotateAround axis angle point

                rotatedDistance =
                    Point3d.signedDistanceAlong axis rotatedPoint
            in
                Expect.approximately distance rotatedDistance
    in
        Test.fuzz3 Fuzz.point3d Fuzz.axis3d Fuzz.scalar description expectation


jsonRoundTrips : Test
jsonRoundTrips =
    Generic.jsonRoundTrips Fuzz.point3d Encode.point3d Decode.point3d


suite : Test
suite =
    Test.describe "OpenSolid.Core.Point3d"
        [ rotationAboutAxisPreservesDistance
        , jsonRoundTrips
        ]


main : Program Never
main =
    Html.run suite<commit_msg>Add Point3d rotation/radial distance test<commit_after>{- This Source Code Form is subject to the terms of the Mozilla Public License,
   v. 2.0. If a copy of the MPL was not distributed with this file, you can
   obtain one at http://mozilla.org/MPL/2.0/.

   Copyright 2016 by <NAME>
   <EMAIL>
-}


module Point3d exposing (suite)

import Test exposing (Test)
import Test.Runner.Html as Html
import OpenSolid.Point3d as Point3d
import OpenSolid.Core.Encode as Encode
import OpenSolid.Core.Decode as Decode
import OpenSolid.Core.Fuzz as Fuzz
import OpenSolid.Core.Expect as Expect
import Generic


rotationAboutAxisPreservesDistanceAlong : Test
rotationAboutAxisPreservesDistanceAlong =
    let
        description =
            "Rotation about axis preserves distance along that axis"

        expectation point axis angle =
            let
                distance =
                    Point3d.signedDistanceAlong axis point

                rotatedPoint =
                    Point3d.rotateAround axis angle point

                rotatedDistance =
                    Point3d.signedDistanceAlong axis rotatedPoint
            in
                Expect.approximately distance rotatedDistance
    in
        Test.fuzz3 Fuzz.point3d Fuzz.axis3d Fuzz.scalar description expectation


rotationAboutAxisPreservesRadialDistance : Test
rotationAboutAxisPreservesRadialDistance =
    let
        description =
            "Rotation about axis preserves radial distance from that axis"

        expectation point axis angle =
            let
                radialDistance =
                    Point3d.radialDistanceFrom axis point

                rotatedPoint =
                    Point3d.rotateAround axis angle point

                rotatedDistance =
                    Point3d.radialDistanceFrom axis rotatedPoint
            in
                Expect.approximately radialDistance rotatedDistance
    in
        Test.fuzz3 Fuzz.point3d Fuzz.axis3d Fuzz.scalar description expectation


jsonRoundTrips : Test
jsonRoundTrips =
    Generic.jsonRoundTrips Fuzz.point3d Encode.point3d Decode.point3d


suite : Test
suite =
    Test.describe "OpenSolid.Core.Point3d"
        [ rotationAboutAxisPreservesDistanceAlong
        , rotationAboutAxisPreservesRadialDistance
        , jsonRoundTrips
        ]


main : Program Never
main =
    Html.run suite
{'fraction_non_alphanumeric': 0.043812451960030745, 'fraction_numerical': 0.012554445298488343, 'mean_word_length': 2.3510729613733905, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4762864', 'n_tokens_mistral': 1077, 'n_tokens_neox': 978, 'n_words': 319}