{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Rekognition.Types.Pose
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Rekognition.Types.Pose where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Indicates the pose of the face as determined by its pitch, roll, and
-- yaw.
--
-- /See:/ 'newPose' smart constructor.
data Pose = Pose'
  { -- | Value representing the face rotation on the yaw axis.
    Pose -> Maybe Double
yaw :: Prelude.Maybe Prelude.Double,
    -- | Value representing the face rotation on the roll axis.
    Pose -> Maybe Double
roll :: Prelude.Maybe Prelude.Double,
    -- | Value representing the face rotation on the pitch axis.
    Pose -> Maybe Double
pitch :: Prelude.Maybe Prelude.Double
  }
  deriving (Pose -> Pose -> Bool
(Pose -> Pose -> Bool) -> (Pose -> Pose -> Bool) -> Eq Pose
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Pose -> Pose -> Bool
$c/= :: Pose -> Pose -> Bool
== :: Pose -> Pose -> Bool
$c== :: Pose -> Pose -> Bool
Prelude.Eq, ReadPrec [Pose]
ReadPrec Pose
Int -> ReadS Pose
ReadS [Pose]
(Int -> ReadS Pose)
-> ReadS [Pose] -> ReadPrec Pose -> ReadPrec [Pose] -> Read Pose
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Pose]
$creadListPrec :: ReadPrec [Pose]
readPrec :: ReadPrec Pose
$creadPrec :: ReadPrec Pose
readList :: ReadS [Pose]
$creadList :: ReadS [Pose]
readsPrec :: Int -> ReadS Pose
$creadsPrec :: Int -> ReadS Pose
Prelude.Read, Int -> Pose -> ShowS
[Pose] -> ShowS
Pose -> String
(Int -> Pose -> ShowS)
-> (Pose -> String) -> ([Pose] -> ShowS) -> Show Pose
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Pose] -> ShowS
$cshowList :: [Pose] -> ShowS
show :: Pose -> String
$cshow :: Pose -> String
showsPrec :: Int -> Pose -> ShowS
$cshowsPrec :: Int -> Pose -> ShowS
Prelude.Show, (forall x. Pose -> Rep Pose x)
-> (forall x. Rep Pose x -> Pose) -> Generic Pose
forall x. Rep Pose x -> Pose
forall x. Pose -> Rep Pose x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Pose x -> Pose
$cfrom :: forall x. Pose -> Rep Pose x
Prelude.Generic)

-- |
-- Create a value of 'Pose' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'yaw', 'pose_yaw' - Value representing the face rotation on the yaw axis.
--
-- 'roll', 'pose_roll' - Value representing the face rotation on the roll axis.
--
-- 'pitch', 'pose_pitch' - Value representing the face rotation on the pitch axis.
newPose ::
  Pose
newPose :: Pose
newPose =
  Pose' :: Maybe Double -> Maybe Double -> Maybe Double -> Pose
Pose'
    { $sel:yaw:Pose' :: Maybe Double
yaw = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:roll:Pose' :: Maybe Double
roll = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:pitch:Pose' :: Maybe Double
pitch = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | Value representing the face rotation on the yaw axis.
pose_yaw :: Lens.Lens' Pose (Prelude.Maybe Prelude.Double)
pose_yaw :: (Maybe Double -> f (Maybe Double)) -> Pose -> f Pose
pose_yaw = (Pose -> Maybe Double)
-> (Pose -> Maybe Double -> Pose)
-> Lens Pose Pose (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Pose' {Maybe Double
yaw :: Maybe Double
$sel:yaw:Pose' :: Pose -> Maybe Double
yaw} -> Maybe Double
yaw) (\s :: Pose
s@Pose' {} Maybe Double
a -> Pose
s {$sel:yaw:Pose' :: Maybe Double
yaw = Maybe Double
a} :: Pose)

-- | Value representing the face rotation on the roll axis.
pose_roll :: Lens.Lens' Pose (Prelude.Maybe Prelude.Double)
pose_roll :: (Maybe Double -> f (Maybe Double)) -> Pose -> f Pose
pose_roll = (Pose -> Maybe Double)
-> (Pose -> Maybe Double -> Pose)
-> Lens Pose Pose (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Pose' {Maybe Double
roll :: Maybe Double
$sel:roll:Pose' :: Pose -> Maybe Double
roll} -> Maybe Double
roll) (\s :: Pose
s@Pose' {} Maybe Double
a -> Pose
s {$sel:roll:Pose' :: Maybe Double
roll = Maybe Double
a} :: Pose)

-- | Value representing the face rotation on the pitch axis.
pose_pitch :: Lens.Lens' Pose (Prelude.Maybe Prelude.Double)
pose_pitch :: (Maybe Double -> f (Maybe Double)) -> Pose -> f Pose
pose_pitch = (Pose -> Maybe Double)
-> (Pose -> Maybe Double -> Pose)
-> Lens Pose Pose (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Pose' {Maybe Double
pitch :: Maybe Double
$sel:pitch:Pose' :: Pose -> Maybe Double
pitch} -> Maybe Double
pitch) (\s :: Pose
s@Pose' {} Maybe Double
a -> Pose
s {$sel:pitch:Pose' :: Maybe Double
pitch = Maybe Double
a} :: Pose)

instance Core.FromJSON Pose where
  parseJSON :: Value -> Parser Pose
parseJSON =
    String -> (Object -> Parser Pose) -> Value -> Parser Pose
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Pose"
      ( \Object
x ->
          Maybe Double -> Maybe Double -> Maybe Double -> Pose
Pose'
            (Maybe Double -> Maybe Double -> Maybe Double -> Pose)
-> Parser (Maybe Double)
-> Parser (Maybe Double -> Maybe Double -> Pose)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Yaw")
            Parser (Maybe Double -> Maybe Double -> Pose)
-> Parser (Maybe Double) -> Parser (Maybe Double -> Pose)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Roll")
            Parser (Maybe Double -> Pose)
-> Parser (Maybe Double) -> Parser Pose
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Pitch")
      )

instance Prelude.Hashable Pose

instance Prelude.NFData Pose