ARGoS 3
A parallel, multi-engine simulator for swarm robotics
lua_vector2.h
Go to the documentation of this file.
1#ifndef LUA_VECTOR2_H
2#define LUA_VECTOR2_H
3
10extern "C" {
11#include <lua.h>
12#include <lualib.h>
13#include <lauxlib.h>
14}
15
16#include <argos3/core/utility/datatypes/datatypes.h>
17#include <argos3/core/utility/math/vector2.h>
18
19#include <string>
20#include <utility>
21
22namespace argos {
23
25
26 public:
27
28 static void RegisterType(lua_State* pt_state);
29
30 static const std::string& GetTypeId() {
31 return m_strTypeId;
32 }
33
34 static int Create(lua_State* pt_state);
35
36 template<class... TArguments>
37 static void PushVector2(lua_State* pt_state, TArguments&&... t_arguments) {
38 /* allocate memory for a CVector2 */
39 void* pvUserdatum =
40 lua_newuserdata(pt_state, sizeof(CVector2));
41 /* run the constructor on the allocated memory */
42 new (pvUserdatum) CVector2(std::forward<TArguments>(t_arguments)...);
43 /* set the metatable for the userdatum */
44 luaL_getmetatable(pt_state, m_strTypeId.c_str());
45 lua_setmetatable(pt_state, -2);
46 }
47
48 static CVector2& ToVector2(lua_State* pt_state, int n_index);
49
50 static int Index(lua_State* pt_state);
51
52 static int NewIndex(lua_State* pt_state);
53
54 static int ToString(lua_State* pt_state);
55
56 static int Equal(lua_State* pt_state);
57
58 static int Add(lua_State* pt_state);
59
60 static int Multiply(lua_State* pt_state);
61
62 static int Subtract(lua_State* pt_state);
63
64 static int UnaryMinus(lua_State* pt_state);
65
66 static int Normalize(lua_State* pt_state);
67
68 static int Length(lua_State* pt_state);
69
70 static int DotProduct(lua_State* pt_state);
71
72 static int CrossProduct(lua_State* pt_state);
73
74 static int Rotate(lua_State* pt_state);
75
76 private:
77
78 static const std::string m_strTypeId;
79
80 };
81
82}
83
84#endif
The namespace containing all the ARGoS related code.
Definition ci_actuator.h:12
A 2D vector class.
Definition vector2.h:27
static int Multiply(lua_State *pt_state)
static int Add(lua_State *pt_state)
static int CrossProduct(lua_State *pt_state)
static int UnaryMinus(lua_State *pt_state)
static int Length(lua_State *pt_state)
static int NewIndex(lua_State *pt_state)
static void RegisterType(lua_State *pt_state)
static int Rotate(lua_State *pt_state)
static int DotProduct(lua_State *pt_state)
static int Index(lua_State *pt_state)
static CVector2 & ToVector2(lua_State *pt_state, int n_index)
static int Equal(lua_State *pt_state)
static void PushVector2(lua_State *pt_state, TArguments &&... t_arguments)
Definition lua_vector2.h:37
static const std::string & GetTypeId()
Definition lua_vector2.h:30
static int ToString(lua_State *pt_state)
static int Subtract(lua_State *pt_state)
static int Normalize(lua_State *pt_state)
static int Create(lua_State *pt_state)