PhotoGENius V1.0.0
A basic library for generating photorealistic images, developed for the course Numerical techniques for photorealistic image generation.
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
PGENLib.Vec Struct Reference

A 3D vector. This class has three floating-point fields: x, y, and z. More...

Public Member Functions

 Vec ()
 Empty constructor.
 
 Vec (float x, float y, float z)
 Constructor with float parameters. More...
 
override string ToString ()
 Returns vector's components x, y, z as a string. More...
 
Vec Neg ()
 Return the reversed vector. More...
 
Vec NormalizeVec ()
 Normalize the vector, so that it's norm is equal to 1. More...
 
Normal VecToNorm ()
 Turns a vector in a normal, and returns the normal. More...
 

Static Public Member Functions

static bool are_close (Vec p, Vec q)
 Check if two vectors are similar enough to be considered equal.
 
static Vec operator+ (Vec v, Vec w)
 Returns the sum of two vectors. More...
 
static Vec operator- (Vec v, Vec w)
 Returns the difference between two vectors. More...
 
static Vec operator* (Vec v, float s)
 Returns the product between a vector and a scalar. More...
 
static Vec operator/ (Vec v, float s)
 Returns the division between a vector and a float, which is a vector. More...
 
static Vec operator- (Vec a)
 Return the reversed vector. More...
 
static float DotProd (Vec v, Vec w)
 Returns the dot product between two vectors. More...
 
static Vec CrossProduct (Vec v, Vec w)
 Returns the cross product between two vectors. More...
 
static float SquaredNorm (Vec v)
 Return the squared norm (Euclidean length) of a vector. More...
 
static float Norm (Vec v)
 Return the norm (Euclidean length) of a vector. More...
 
static Tuple CreateOnbFromZ (Normal e3)
 Create a orthonormal basis (Onb) from a vector representing the z axis (which must be normalized). More...
 
static float NormalizeDot (Vec v1, Vec v2)
 Normalize two vectors or normals and evaluate the dot product. The result is the cosine of the angle between the two vectors/normals. More...
 
static float NormalizeDot (Normal v1, Normal v2)
 Normalize two vectors or normals and evaluate the dot product. The result is the cosine of the angle between the two vectors/normals. More...
 
static float NormalizeDot (Normal v1, Vec v2)
 Normalize two vectors or normals and evaluate the dot product. The result is the cosine of the angle between the two vectors/normals. More...
 
static float NormalizeDot (Vec v1, Normal v2)
 Normalize two vectors or normals and evaluate the dot product. The result is the cosine of the angle between the two vectors/normals. More...
 

Public Attributes

float x
 
float y
 
float z
 

Detailed Description

A 3D vector. This class has three floating-point fields: x, y, and z.

Constructor & Destructor Documentation

◆ Vec()

PGENLib.Vec.Vec ( float  x,
float  y,
float  z 
)

Constructor with float parameters.

Parameters
x
y
z

Member Function Documentation

◆ CreateOnbFromZ()

static Tuple PGENLib.Vec.CreateOnbFromZ ( Normal  e3)
static

Create a orthonormal basis (Onb) from a vector representing the z axis (which must be normalized).

Parameters
e3normalized Normal vector, on the z axis
Returns
Tuple containing the three vectors of the basis, such that e3 = normal

◆ CrossProduct()

static Vec PGENLib.Vec.CrossProduct ( Vec  v,
Vec  w 
)
static

Returns the cross product between two vectors.

Parameters
v
w
Returns

◆ DotProd()

static float PGENLib.Vec.DotProd ( Vec  v,
Vec  w 
)
static

Returns the dot product between two vectors.

Parameters
v
w
Returns

◆ Neg()

Vec PGENLib.Vec.Neg ( )

Return the reversed vector.

Returns

◆ Norm()

static float PGENLib.Vec.Norm ( Vec  v)
static

Return the norm (Euclidean length) of a vector.

Parameters
v
Returns

◆ NormalizeDot() [1/4]

static float PGENLib.Vec.NormalizeDot ( Normal  v1,
Normal  v2 
)
static

Normalize two vectors or normals and evaluate the dot product. The result is the cosine of the angle between the two vectors/normals.

Parameters
v1Normal
v2Normal
Returns
a float representing the cosine of the angle between the two vecors/normals.

◆ NormalizeDot() [2/4]

static float PGENLib.Vec.NormalizeDot ( Normal  v1,
Vec  v2 
)
static

Normalize two vectors or normals and evaluate the dot product. The result is the cosine of the angle between the two vectors/normals.

Parameters
v1Normal
v2Vec
Returns
a float representing the cosine of the angle between the two vecors/normals.

◆ NormalizeDot() [3/4]

static float PGENLib.Vec.NormalizeDot ( Vec  v1,
Normal  v2 
)
static

Normalize two vectors or normals and evaluate the dot product. The result is the cosine of the angle between the two vectors/normals.

Parameters
v1Vec
v2Normal
Returns
a float representing the cosine of the angle between the two vecors/normals.

◆ NormalizeDot() [4/4]

static float PGENLib.Vec.NormalizeDot ( Vec  v1,
Vec  v2 
)
static

Normalize two vectors or normals and evaluate the dot product. The result is the cosine of the angle between the two vectors/normals.

Parameters
v1Vector
v2Vector
Returns
a float representing the cosine of the angle between the two vecors/normals.

◆ NormalizeVec()

Vec PGENLib.Vec.NormalizeVec ( )

Normalize the vector, so that it's norm is equal to 1.

Returns

◆ operator*()

static Vec PGENLib.Vec.operator* ( Vec  v,
float  s 
)
static

Returns the product between a vector and a scalar.

Parameters
v
s
Returns

◆ operator+()

static Vec PGENLib.Vec.operator+ ( Vec  v,
Vec  w 
)
static

Returns the sum of two vectors.

Parameters
v
w
Returns

◆ operator-() [1/2]

static Vec PGENLib.Vec.operator- ( Vec  a)
static

Return the reversed vector.

Parameters
a
Returns

◆ operator-() [2/2]

static Vec PGENLib.Vec.operator- ( Vec  v,
Vec  w 
)
static

Returns the difference between two vectors.

Parameters
v
w
Returns

◆ operator/()

static Vec PGENLib.Vec.operator/ ( Vec  v,
float  s 
)
static

Returns the division between a vector and a float, which is a vector.

Parameters
v
s
Returns
a vector

◆ SquaredNorm()

static float PGENLib.Vec.SquaredNorm ( Vec  v)
static

Return the squared norm (Euclidean length) of a vector.

Parameters
v
Returns

◆ ToString()

override string PGENLib.Vec.ToString ( )

Returns vector's components x, y, z as a string.

Returns

◆ VecToNorm()

Normal PGENLib.Vec.VecToNorm ( )

Turns a vector in a normal, and returns the normal.

Returns

The documentation for this struct was generated from the following file: