manganese_serialization_kit v0.2.4 Manganese.SerializationKit.Structs.UnityQuaternion

A Unity quaternion value with :x, :y, :z, and w components.

Note that Unity structs are available in order to process the data in the API server, but most vector calculations occur in the environment simulation service.

This module can be used as an Ecto type for de/serialization when interacting with the database.

Link to this section Summary

Types

t()

A Unity quaternion.

Functions

Casts the given input to the custom type.

Dumps the given term into an Ecto native type.

Deserialize a quaternion from a map.

Deserialize a quaternion from a tuple.

A quaternion representing no rotation.

Loads the given term into a custom type.

Serialize a quaternion to a map.

Serialize a quaternion to a tuple.

The PostgreSQL composite type used to represent a quaternion.

Link to this section Types

Link to this type

t()
t() :: %Manganese.SerializationKit.Structs.UnityQuaternion{
  w: float(),
  x: float(),
  y: float(),
  z: float()
}

A Unity quaternion.

Link to this type

t_external()
t_external() :: map()

Link to this type

t_internal()
t_internal() :: {float(), float(), float(), float()}

Link to this section Functions

Link to this function

cast(unity_quaternion)

Casts the given input to the custom type.

This callback is called on external input and can return any type, as long as the dump/1 function is able to convert the returned value into an Ecto native type. There are two situations where this callback is called:

  1. When casting values by Ecto.Changeset
  2. When passing arguments to Ecto.Query

Callback implementation for Ecto.Type.cast/1.

Link to this function

dump(unity_quaternion)

Dumps the given term into an Ecto native type.

This callback is called with any term that was stored in the struct and it needs to validate them and convert it to an Ecto native type.

Callback implementation for Ecto.Type.dump/1.

Link to this function

from_map(map)
from_map(t_external()) :: t()

Deserialize a quaternion from a map.

Link to this function

from_tuple(arg)
from_tuple(t_internal()) :: t()

Deserialize a quaternion from a tuple.

Link to this function

identity()
identity() :: t()

A quaternion representing no rotation.

Loads the given term into a custom type.

This callback is called when loading data from the database and receive an Ecto native type. It can return any type, as long as the dump/1 function is able to convert the returned value back into an Ecto native type.

Callback implementation for Ecto.Type.load/1.

Link to this function

to_map(unity_quaternion)
to_map(t()) :: t_external()

Serialize a quaternion to a map.

Link to this function

to_tuple(unity_quaternion)
to_tuple(t()) :: t_internal()

Serialize a quaternion to a tuple.

Link to this function

type()
type() :: :unity_quaternion

The PostgreSQL composite type used to represent a quaternion.