-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector.h
More file actions
66 lines (52 loc) · 1.6 KB
/
vector.h
File metadata and controls
66 lines (52 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* $Id: vector.h,v 1.7 2003/05/27 09:36:39 cluijten Exp $ */
#ifndef VECTOR_H
#define VECTOR_H
#include <stdio.h>
/* Vector ADT */
/** Vector
* Simple vector typing representing a (X, Y) tuple.
*/
typedef struct {
float x; /**< X coordinate */
float y; /**< Y coordinate */
} Vector;
/** Creates a vector.
* \param x X coordinate
* \param y Y coordinate
*/
Vector * new_vector(float x, float y);
/** Destroys a vector.
* \param v Pointer to vector to be destroyed.
*/
void del_vector(Vector *v);
/** Checks if given vectors are equal. */
inline int vectors_equal(Vector *v1, Vector *v2);
/** Copies a vector into memory.
* \param oldvector Pointer to vector to be copied.
*/
Vector * copy_vector(Vector * oldvector);
/** Calculates the distance between two vectors
* \param v1 and \param v2 are Pointers to vector to be calculated.
*/
float vector_dist(Vector *v1, Vector *v2);
/** Scalar multiplication
* \param v Pointer to vector to be multiplied
* \param l Scalar of the multiplication
*/
Vector * vector_scal_mul(Vector *v, float l);
/** Vector multiplication
* \param v1 and \param v2 Pointers to vectors to be multiplied
*/
Vector * vector_mul(Vector *v1, Vector *v2);
/** Vector addition
* \param v1 and \param v2 Pointers to vectors to be added
*/
Vector * vector_add(Vector *v1, Vector *v2);
/** Vector normailization
* \param v Pointer to vector to be normalized (in place)
* \param dimension Maximal value to which the vector shall be normalized (> 0)
*
* Returns true if vector changed, false otherwise
*/
int vector_normalize(Vector *v, int dimension);
#endif /* VECTOR_H */