Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implement kmVec2Assign

  • Loading branch information...
commit af9f66b03d39e9d2187d477d600f08180222e6a5 1 parent e25d39d
@Kazade authored
Showing with 17 additions and 0 deletions.
  1. +15 −0 kazmath/vec2.c
  2. +2 −0  kazmath/vec2.h
View
15 kazmath/vec2.c
@@ -116,3 +116,18 @@ int kmVec2AreEqual(const kmVec2* p1, const kmVec2* p2)
(p1->y < p2->y + kmEpsilon && p1->y > p2->y - kmEpsilon)
);
}
+
+/**
+ * Assigns pIn to pOut. Returns pOut. If pIn and pOut are the same
+ * then nothing happens but pOut is still returned
+ */
+kmVec2* kmVec2Assign(kmVec2* pOut, const kmVec2* pIn) {
+ if (pOut == pIn) {
+ return pOut;
+ }
+
+ pOut->x = pIn->x;
+ pOut->y = pIn->y;
+
+ return pOut;
+}
View
2  kazmath/vec2.h
@@ -44,6 +44,7 @@ typedef struct kmVec2 {
#ifdef __cplusplus
extern "C" {
#endif
+
kmVec2* kmVec2Fill(kmVec2* pOut, kmScalar x, kmScalar y);
kmScalar kmVec2Length(const kmVec2* pIn); ///< Returns the length of the vector
kmScalar kmVec2LengthSq(const kmVec2* pIn); ///< Returns the square of the length of the vector
@@ -55,6 +56,7 @@ kmVec2* kmVec2Transform(kmVec2* pOut, const kmVec2* pV1, const struct kmMat3* pM
kmVec2* kmVec2TransformCoord(kmVec2* pOut, const kmVec2* pV, const struct kmMat3* pM); ///<Transforms a 2D vector by a given matrix, projecting the result back into w = 1.
kmVec2* kmVec2Scale(kmVec2* pOut, const kmVec2* pIn, const kmScalar s); ///< Scales a vector to length s
int kmVec2AreEqual(const kmVec2* p1, const kmVec2* p2); ///< Returns 1 if both vectors are equal
+kmVec2* kmVec2Assign(kmVec2* pOut, const kmVec2* pIn);
#ifdef __cplusplus
}
Please sign in to comment.
Something went wrong with that request. Please try again.