CougarFFW04 Posted February 22, 2019 Posted February 22, 2019 (edited) Hi, So I facing the most stupid problem you will ever see....:( I check DCS to know what is a Vec2 format and can't find it... :joystick: I thought vec2 would be something like that : myVec2= {x=something, y=something} and I would refer to myVec2.x and myVec2.y but it sounds that I am wrong.... So when a function expect a Vec2 x or Vec2 y coordinate what should I put there... :helpsmilie: How do I code a DCS Vec2 ? Thanks Edited February 22, 2019 by CougarFFW04
Habu_69 Posted February 22, 2019 Posted February 22, 2019 Vec2, as well as Vec3, is, of course, a point in space, but I do not believe a Vec2 can be defined directly. Only times I have used Vec2 I used a variable to obtain it indirectly from a COORDINATE or the position of an object.
Grimes Posted February 22, 2019 Posted February 22, 2019 Vec2 and Vec3 are just names used for a coordinate table so that you know what you are working with and need to include. Sort of like saying "parameter 1 needs to be a string, parameter 2 is a number, etc" But instead it is saying "This needs to be a table, it represents a coordinate and needs to be in vec2 formatting" There is nothing special about it really. The only thing that can be confusing about it is that the y coordinate changes from representing "north/south" to altitude with Vec3. someVec2Coord = {x = whatever, y = whatever} someVec3Coord = {x = whatever, y = whatever, z = whatever} That is literally all there is to it, it is just a table with certain values. Likewise to "convert" them it is pretty straight forward. someVec2 = {x = vec3Coord.x, y = vec3Coord.z} someVec3 = {x = vec2Coord.x, y = whateverYouWantItToBe, z = vec2Coord.y} 1 The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Costas_Ch Posted May 18, 2021 Posted May 18, 2021 (edited) Hi, Please let me know if I got this right: in case of Vec2, x is East/West, y is North/South. in case of Vec3, x is East/West, y is altitude (so I guess can take only positive values (??)), z is North/South. Are Those values distance units? Default as meters? Only meters? Something different? Can those be somehow related to the mission editor's distance tool? Thanks. Edited May 18, 2021 by Costas_Ch
cfrag Posted May 18, 2021 Posted May 18, 2021 (edited) Well, x is x, y is y and z is z. Pedantic, yes, but it's important to keep these concepts separate or DCS *will* confuse you. Many of DCS's routines interpret the x and y components as EW and NS, while others use y as barometric altitude (and I guess if we were ever to have submarines, we can have negative altitude). I can't recall and will have to check, but it might be possible that unit:getPoint() returns x-y-z as NS-alt-EW, some of it was unexpected, probably to conform with a left-handed coordinate system. Doesn't really matter, since once you have figured it out, your code will always get it right Distance units in DCS are meters, and speeds are m/s - a very good choice IMHO (who can't really easily convert 6205 feet into miles, but has no problems converting 1000 meters into 1 km). Since feet and meters can be converted to each other by multiplying or dividing with the same factor, they are definitely related to the distance tool: a meters are a / 0.3048 feet conversely b feet are b * 0.3048 meters. You need to look up the correct conversion factors for nautical miles to meters, and m/s to knots Edited May 18, 2021 by cfrag
toutenglisse Posted May 18, 2021 Posted May 18, 2021 11 hours ago, Costas_Ch said: Hi, Please let me know if I got this right: in case of Vec2, x is East/West, y is North/South. in case of Vec3, x is East/West, y is altitude (so I guess can take only positive values (??)), z is North/South. Are Those values distance units? Default as meters? Only meters? Something different? Can those be somehow related to the mission editor's distance tool? Thanks. You can use LeftAlt+Y several times in mission editor to switch coordinates to the same format used for Vec2/Vec3.
Recommended Posts