{-# 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.IoTRoboRunner.Types.CartesianCoordinates
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTRoboRunner.Types.CartesianCoordinates where

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

-- | Cartesian coordinates in 3D space relative to the RoboRunner origin.
--
-- /See:/ 'newCartesianCoordinates' smart constructor.
data CartesianCoordinates = CartesianCoordinates'
  { -- | Z coordinate.
    CartesianCoordinates -> Maybe Double
z :: Prelude.Maybe Prelude.Double,
    -- | X coordinate.
    CartesianCoordinates -> Double
x :: Prelude.Double,
    -- | Y coordinate.
    CartesianCoordinates -> Double
y :: Prelude.Double
  }
  deriving (CartesianCoordinates -> CartesianCoordinates -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CartesianCoordinates -> CartesianCoordinates -> Bool
$c/= :: CartesianCoordinates -> CartesianCoordinates -> Bool
== :: CartesianCoordinates -> CartesianCoordinates -> Bool
$c== :: CartesianCoordinates -> CartesianCoordinates -> Bool
Prelude.Eq, ReadPrec [CartesianCoordinates]
ReadPrec CartesianCoordinates
Int -> ReadS CartesianCoordinates
ReadS [CartesianCoordinates]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CartesianCoordinates]
$creadListPrec :: ReadPrec [CartesianCoordinates]
readPrec :: ReadPrec CartesianCoordinates
$creadPrec :: ReadPrec CartesianCoordinates
readList :: ReadS [CartesianCoordinates]
$creadList :: ReadS [CartesianCoordinates]
readsPrec :: Int -> ReadS CartesianCoordinates
$creadsPrec :: Int -> ReadS CartesianCoordinates
Prelude.Read, Int -> CartesianCoordinates -> ShowS
[CartesianCoordinates] -> ShowS
CartesianCoordinates -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CartesianCoordinates] -> ShowS
$cshowList :: [CartesianCoordinates] -> ShowS
show :: CartesianCoordinates -> String
$cshow :: CartesianCoordinates -> String
showsPrec :: Int -> CartesianCoordinates -> ShowS
$cshowsPrec :: Int -> CartesianCoordinates -> ShowS
Prelude.Show, forall x. Rep CartesianCoordinates x -> CartesianCoordinates
forall x. CartesianCoordinates -> Rep CartesianCoordinates x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CartesianCoordinates x -> CartesianCoordinates
$cfrom :: forall x. CartesianCoordinates -> Rep CartesianCoordinates x
Prelude.Generic)

-- |
-- Create a value of 'CartesianCoordinates' 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:
--
-- 'z', 'cartesianCoordinates_z' - Z coordinate.
--
-- 'x', 'cartesianCoordinates_x' - X coordinate.
--
-- 'y', 'cartesianCoordinates_y' - Y coordinate.
newCartesianCoordinates ::
  -- | 'x'
  Prelude.Double ->
  -- | 'y'
  Prelude.Double ->
  CartesianCoordinates
newCartesianCoordinates :: Double -> Double -> CartesianCoordinates
newCartesianCoordinates Double
pX_ Double
pY_ =
  CartesianCoordinates'
    { $sel:z:CartesianCoordinates' :: Maybe Double
z = forall a. Maybe a
Prelude.Nothing,
      $sel:x:CartesianCoordinates' :: Double
x = Double
pX_,
      $sel:y:CartesianCoordinates' :: Double
y = Double
pY_
    }

-- | Z coordinate.
cartesianCoordinates_z :: Lens.Lens' CartesianCoordinates (Prelude.Maybe Prelude.Double)
cartesianCoordinates_z :: Lens' CartesianCoordinates (Maybe Double)
cartesianCoordinates_z = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CartesianCoordinates' {Maybe Double
z :: Maybe Double
$sel:z:CartesianCoordinates' :: CartesianCoordinates -> Maybe Double
z} -> Maybe Double
z) (\s :: CartesianCoordinates
s@CartesianCoordinates' {} Maybe Double
a -> CartesianCoordinates
s {$sel:z:CartesianCoordinates' :: Maybe Double
z = Maybe Double
a} :: CartesianCoordinates)

-- | X coordinate.
cartesianCoordinates_x :: Lens.Lens' CartesianCoordinates Prelude.Double
cartesianCoordinates_x :: Lens' CartesianCoordinates Double
cartesianCoordinates_x = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CartesianCoordinates' {Double
x :: Double
$sel:x:CartesianCoordinates' :: CartesianCoordinates -> Double
x} -> Double
x) (\s :: CartesianCoordinates
s@CartesianCoordinates' {} Double
a -> CartesianCoordinates
s {$sel:x:CartesianCoordinates' :: Double
x = Double
a} :: CartesianCoordinates)

-- | Y coordinate.
cartesianCoordinates_y :: Lens.Lens' CartesianCoordinates Prelude.Double
cartesianCoordinates_y :: Lens' CartesianCoordinates Double
cartesianCoordinates_y = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CartesianCoordinates' {Double
y :: Double
$sel:y:CartesianCoordinates' :: CartesianCoordinates -> Double
y} -> Double
y) (\s :: CartesianCoordinates
s@CartesianCoordinates' {} Double
a -> CartesianCoordinates
s {$sel:y:CartesianCoordinates' :: Double
y = Double
a} :: CartesianCoordinates)

instance Data.FromJSON CartesianCoordinates where
  parseJSON :: Value -> Parser CartesianCoordinates
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CartesianCoordinates"
      ( \Object
x ->
          Maybe Double -> Double -> Double -> CartesianCoordinates
CartesianCoordinates'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"z")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"x")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"y")
      )

instance Prelude.Hashable CartesianCoordinates where
  hashWithSalt :: Int -> CartesianCoordinates -> Int
hashWithSalt Int
_salt CartesianCoordinates' {Double
Maybe Double
y :: Double
x :: Double
z :: Maybe Double
$sel:y:CartesianCoordinates' :: CartesianCoordinates -> Double
$sel:x:CartesianCoordinates' :: CartesianCoordinates -> Double
$sel:z:CartesianCoordinates' :: CartesianCoordinates -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
z
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
x
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
y

instance Prelude.NFData CartesianCoordinates where
  rnf :: CartesianCoordinates -> ()
rnf CartesianCoordinates' {Double
Maybe Double
y :: Double
x :: Double
z :: Maybe Double
$sel:y:CartesianCoordinates' :: CartesianCoordinates -> Double
$sel:x:CartesianCoordinates' :: CartesianCoordinates -> Double
$sel:z:CartesianCoordinates' :: CartesianCoordinates -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
z
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
x
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
y

instance Data.ToJSON CartesianCoordinates where
  toJSON :: CartesianCoordinates -> Value
toJSON CartesianCoordinates' {Double
Maybe Double
y :: Double
x :: Double
z :: Maybe Double
$sel:y:CartesianCoordinates' :: CartesianCoordinates -> Double
$sel:x:CartesianCoordinates' :: CartesianCoordinates -> Double
$sel:z:CartesianCoordinates' :: CartesianCoordinates -> Maybe Double
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"z" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
z,
            forall a. a -> Maybe a
Prelude.Just (Key
"x" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
x),
            forall a. a -> Maybe a
Prelude.Just (Key
"y" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
y)
          ]
      )