Class Vec4

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Vec4 extends ProxyInstance

A structure capable of holding a vector with four dimensions: x, y, z, and w.

The contents of the graphene_vec4_t structure are private and should never be accessed directly.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Allocate a new Vec4.
    Vec4(Arena arena)
    Allocate a new Vec4.
    Create a Vec4 proxy instance for the provided memory address.
    Vec4(Simd4F value)
    Allocate a new Vec4 with the fields set to the provided values.
    Vec4(Simd4F value, Arena arena)
    Allocate a new Vec4 with the fields set to the provided values.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(Vec4 b, Vec4 res)
    Adds each component of the two given vectors.
    static Vec4
    Allocates a new graphene_vec4_t structure.
    void
    divide(Vec4 b, Vec4 res)
    Divides each component of the first operand this Vec4 by the corresponding component of the second operand b, and places the results into the vector res.
    float
    dot(Vec4 b)
    Computes the dot product of the two given vectors.
    boolean
    equal(Vec4 v2)
    Checks whether the two given graphene_vec4_t are equal.
    void
    Frees the resources allocated by this Vec4
    The memory layout of the native struct.
    static @Nullable Type
    Get the GType of the Vec4 class.
    float
    Retrieves the value of the fourth component of the given graphene_vec4_t.
    float
    Retrieves the value of the first component of the given graphene_vec4_t.
    void
    getXy(Vec2 res)
    Creates a graphene_vec2_t that contains the first two components of the given graphene_vec4_t.
    void
    getXyz(Vec3 res)
    Creates a graphene_vec3_t that contains the first three components of the given graphene_vec4_t.
    float
    Retrieves the value of the second component of the given graphene_vec4_t.
    float
    Retrieves the value of the third component of the given graphene_vec4_t.
    init(float x, float y, float z, float w)
    Initializes a graphene_vec4_t using the given values.
    initFromFloat(@Nullable float @Nullable [] src)
    Initializes a graphene_vec4_t with the values inside the given array.
    initFromVec2(Vec2 src, float z, float w)
    Initializes a graphene_vec4_t using the components of a graphene_vec2_t and the values of z and w.
    initFromVec3(Vec3 src, float w)
    Initializes a graphene_vec4_t using the components of a graphene_vec3_t and the value of w.
    Initializes a graphene_vec4_t using the components of another graphene_vec4_t.
    void
    interpolate(Vec4 v2, double factor, Vec4 res)
    Linearly interpolates this Vec4 and v2 using the given factor.
    float
    Computes the length of the given graphene_vec4_t.
    void
    max(Vec4 b, Vec4 res)
    Compares each component of the two given vectors and creates a vector that contains the maximum values.
    void
    min(Vec4 b, Vec4 res)
    Compares each component of the two given vectors and creates a vector that contains the minimum values.
    void
    multiply(Vec4 b, Vec4 res)
    Multiplies each component of the two given vectors.
    boolean
    near(Vec4 v2, float epsilon)
    Compares the two given graphene_vec4_t vectors and checks whether their values are within the given epsilon.
    void
    negate(Vec4 res)
    Negates the given graphene_vec4_t.
    void
    Normalizes the given graphene_vec4_t.
    static Vec4
    one()
    Retrieves a pointer to a graphene_vec4_t with all its components set to 1.
    @Nullable Simd4F
    Read the value of the field value.
    void
    scale(float factor, Vec4 res)
    Multiplies all components of the given vector with the given scalar factor.
    void
    subtract(Vec4 b, Vec4 res)
    Subtracts from each component of the first operand this Vec4 the corresponding component of the second operand b and places each result into the components of res.
    void
    toFloat(@Nullable Out<float[]> dest)
    Stores the components of the given graphene_vec4_t into an array of floating point values.
    static Vec4
    Retrieves a pointer to a graphene_vec4_t with its components set to (0, 0, 0, 1).
    void
    writeValue(@Nullable Simd4F value)
    Write a value in the field value.
    static Vec4
    Retrieves a pointer to a graphene_vec4_t with its components set to (1, 0, 0, 0).
    static Vec4
    Retrieves a pointer to a graphene_vec4_t with its components set to (0, 1, 0, 0).
    static Vec4
    Retrieves a pointer to a graphene_vec4_t with its components set to (0, 0, 1, 0).
    static Vec4
    Retrieves a pointer to a graphene_vec4_t with all its components set to 0.

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Vec4

      public Vec4(MemorySegment address)
      Create a Vec4 proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Vec4

      public Vec4(Arena arena)
      Allocate a new Vec4.
      Parameters:
      arena - to control the memory allocation scope
    • Vec4

      public Vec4()
      Allocate a new Vec4. The memory is allocated with Arena.ofAuto().
    • Vec4

      public Vec4(Simd4F value, Arena arena)
      Allocate a new Vec4 with the fields set to the provided values.
      Parameters:
      value - value for the field value
      arena - to control the memory allocation scope
    • Vec4

      public Vec4(Simd4F value)
      Allocate a new Vec4 with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      value - value for the field value
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Vec4 class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readValue

      public @Nullable Simd4F readValue()
      Read the value of the field value.
      Returns:
      The value of the field value
    • writeValue

      public void writeValue(@Nullable Simd4F value)
      Write a value in the field value.
      Parameters:
      value - The new value for the field value
    • alloc

      public static Vec4 alloc()

      Allocates a new graphene_vec4_t structure.

      The contents of the returned structure are undefined.

      Use graphene_vec4_init() to initialize the vector.

      Returns:
      the newly allocated graphene_vec4_t structure. Use graphene_vec4_free() to free the resources allocated by this function.
      Since:
      1.0
    • one

      public static Vec4 one()
      Retrieves a pointer to a graphene_vec4_t with all its components set to 1.
      Returns:
      a constant vector
      Since:
      1.0
    • wAxis

      public static Vec4 wAxis()
      Retrieves a pointer to a graphene_vec4_t with its components set to (0, 0, 0, 1).
      Returns:
      a constant vector
      Since:
      1.0
    • xAxis

      public static Vec4 xAxis()
      Retrieves a pointer to a graphene_vec4_t with its components set to (1, 0, 0, 0).
      Returns:
      a constant vector
      Since:
      1.0
    • yAxis

      public static Vec4 yAxis()
      Retrieves a pointer to a graphene_vec4_t with its components set to (0, 1, 0, 0).
      Returns:
      a constant vector
      Since:
      1.0
    • zAxis

      public static Vec4 zAxis()
      Retrieves a pointer to a graphene_vec4_t with its components set to (0, 0, 1, 0).
      Returns:
      a constant vector
      Since:
      1.0
    • zero

      public static Vec4 zero()
      Retrieves a pointer to a graphene_vec4_t with all its components set to 0.
      Returns:
      a constant vector
      Since:
      1.0
    • add

      public void add(Vec4 b, Vec4 res)
      Adds each component of the two given vectors.
      Parameters:
      b - a graphene_vec4_t
      res - return location for the resulting vector
      Since:
      1.0
    • divide

      public void divide(Vec4 b, Vec4 res)
      Divides each component of the first operand this Vec4 by the corresponding component of the second operand b, and places the results into the vector res.
      Parameters:
      b - a graphene_vec4_t
      res - return location for the resulting vector
      Since:
      1.0
    • dot

      public float dot(Vec4 b)
      Computes the dot product of the two given vectors.
      Parameters:
      b - a graphene_vec4_t
      Returns:
      the value of the dot product
      Since:
      1.0
    • equal

      public boolean equal(Vec4 v2)
      Checks whether the two given graphene_vec4_t are equal.
      Parameters:
      v2 - a graphene_vec4_t
      Returns:
      true if the two vectors are equal, and false otherwise
      Since:
      1.2
    • free

      public void free()
      Frees the resources allocated by this Vec4
      Since:
      1.0
    • getW

      public float getW()
      Retrieves the value of the fourth component of the given graphene_vec4_t.
      Returns:
      the value of the fourth component
      Since:
      1.0
    • getX

      public float getX()
      Retrieves the value of the first component of the given graphene_vec4_t.
      Returns:
      the value of the first component
      Since:
      1.0
    • getXy

      public void getXy(Vec2 res)
      Creates a graphene_vec2_t that contains the first two components of the given graphene_vec4_t.
      Parameters:
      res - return location for a graphene_vec2_t
      Since:
      1.0
    • getXyz

      public void getXyz(Vec3 res)
      Creates a graphene_vec3_t that contains the first three components of the given graphene_vec4_t.
      Parameters:
      res - return location for a graphene_vec3_t
      Since:
      1.0
    • getY

      public float getY()
      Retrieves the value of the second component of the given graphene_vec4_t.
      Returns:
      the value of the second component
      Since:
      1.0
    • getZ

      public float getZ()
      Retrieves the value of the third component of the given graphene_vec4_t.
      Returns:
      the value of the third component
      Since:
      1.0
    • init

      public Vec4 init(float x, float y, float z, float w)

      Initializes a graphene_vec4_t using the given values.

      This function can be called multiple times.

      Parameters:
      x - the X field of the vector
      y - the Y field of the vector
      z - the Z field of the vector
      w - the W field of the vector
      Returns:
      a pointer to the initialized vector
      Since:
      1.0
    • initFromFloat

      public Vec4 initFromFloat(@Nullable float @Nullable [] src)
      Initializes a graphene_vec4_t with the values inside the given array.
      Parameters:
      src - an array of four floating point values
      Returns:
      the initialized vector
      Throws:
      IllegalArgumentException - when length of src is less than 4
      Since:
      1.0
    • initFromVec2

      public Vec4 initFromVec2(Vec2 src, float z, float w)
      Initializes a graphene_vec4_t using the components of a graphene_vec2_t and the values of z and w.
      Parameters:
      src - a graphene_vec2_t
      z - the value for the third component of this Vec4
      w - the value for the fourth component of this Vec4
      Returns:
      the initialized vector
      Since:
      1.0
    • initFromVec3

      public Vec4 initFromVec3(Vec3 src, float w)
      Initializes a graphene_vec4_t using the components of a graphene_vec3_t and the value of w.
      Parameters:
      src - a graphene_vec3_t
      w - the value for the fourth component of this Vec4
      Returns:
      the initialized vector
      Since:
      1.0
    • initFromVec4

      public Vec4 initFromVec4(Vec4 src)
      Initializes a graphene_vec4_t using the components of another graphene_vec4_t.
      Parameters:
      src - a graphene_vec4_t
      Returns:
      the initialized vector
      Since:
      1.0
    • interpolate

      public void interpolate(Vec4 v2, double factor, Vec4 res)
      Linearly interpolates this Vec4 and v2 using the given factor.
      Parameters:
      v2 - a graphene_vec4_t
      factor - the interpolation factor
      res - the interpolated vector
      Since:
      1.10
    • length

      public float length()
      Computes the length of the given graphene_vec4_t.
      Returns:
      the length of the vector
      Since:
      1.0
    • max

      public void max(Vec4 b, Vec4 res)
      Compares each component of the two given vectors and creates a vector that contains the maximum values.
      Parameters:
      b - a graphene_vec4_t
      res - return location for the result vector
      Since:
      1.0
    • min

      public void min(Vec4 b, Vec4 res)
      Compares each component of the two given vectors and creates a vector that contains the minimum values.
      Parameters:
      b - a graphene_vec4_t
      res - return location for the result vector
      Since:
      1.0
    • multiply

      public void multiply(Vec4 b, Vec4 res)
      Multiplies each component of the two given vectors.
      Parameters:
      b - a graphene_vec4_t
      res - return location for the resulting vector
      Since:
      1.0
    • near

      public boolean near(Vec4 v2, float epsilon)
      Compares the two given graphene_vec4_t vectors and checks whether their values are within the given epsilon.
      Parameters:
      v2 - a graphene_vec4_t
      epsilon - the threshold between the two vectors
      Returns:
      true if the two vectors are near each other
      Since:
      1.2
    • negate

      public void negate(Vec4 res)
      Negates the given graphene_vec4_t.
      Parameters:
      res - return location for the result vector
      Since:
      1.2
    • normalize

      public void normalize(Vec4 res)
      Normalizes the given graphene_vec4_t.
      Parameters:
      res - return location for the normalized vector
      Since:
      1.0
    • scale

      public void scale(float factor, Vec4 res)
      Multiplies all components of the given vector with the given scalar factor.
      Parameters:
      factor - the scalar factor
      res - return location for the result vector
      Since:
      1.2
    • subtract

      public void subtract(Vec4 b, Vec4 res)
      Subtracts from each component of the first operand this Vec4 the corresponding component of the second operand b and places each result into the components of res.
      Parameters:
      b - a graphene_vec4_t
      res - return location for the resulting vector
      Since:
      1.0
    • toFloat

      public void toFloat(@Nullable Out<float[]> dest)
      Stores the components of the given graphene_vec4_t into an array of floating point values.
      Parameters:
      dest - return location for an array of floating point values
      Since:
      1.0