From 3568f271506ff94db18a0403624b70ca1332cf29 Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 24 Sep 2023 22:46:50 +0200 Subject: [PATCH] Vector --- Moose Development/Moose/Core/Vector.lua | 11 +++++++-- Moose Development/Moose/Navigation/Point.lua | 26 +++++++++++++++----- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/Core/Vector.lua b/Moose Development/Moose/Core/Vector.lua index d85d76448..9ed6da217 100644 --- a/Moose Development/Moose/Core/Vector.lua +++ b/Moose Development/Moose/Core/Vector.lua @@ -141,7 +141,9 @@ VECTOR.__index = VECTOR -- ToDo list ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- TODO: A lot... +-- TODO: 3D rotation +-- TODO: Markers +-- TODO: Documentation ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Constructor @@ -1063,6 +1065,8 @@ end function VECTOR.__div(a, b) assert(VECTOR._IsVector(a) and type(b) == "number", "div: wrong argument types (expected and )") + + env.info("FF __div") local c=VECTOR:New(a.x/b, a.y/b, a.z/b) @@ -1081,7 +1085,10 @@ end -- @param #VECTOR b Vector b. -- @return #boolean If `true`, both vectors are equal function VECTOR.__eq(a, b) - assert(VECTOR._IsVector(a) and VECTOR._IsVector(b), "ERROR in VECTOR.__eq: wrong argument types: (expected and )") + --assert(VECTOR._IsVector(a) and VECTOR._IsVector(b), "ERROR in VECTOR.__eq: wrong argument types: (expected and )") + env.info("FF __eq",showMessageBox) + BASE:I(a) + BASE:I(b) return a.x==b.x and a.y==b.y and a.z==b.z end diff --git a/Moose Development/Moose/Navigation/Point.lua b/Moose Development/Moose/Navigation/Point.lua index 3aa86f901..d0d06ace7 100644 --- a/Moose Development/Moose/Navigation/Point.lua +++ b/Moose Development/Moose/Navigation/Point.lua @@ -97,7 +97,7 @@ function NAVAID:New(ZoneName, SceneryName, Type) self.zone=ZONE:FindByName(ZoneName) - self.coordinate=self.zone:GetCoordinate() + self=self.zone:GetCoordinate() if SceneryName then self.scenery=SCENERY:FindByNameInZone(SceneryName, ZoneName) @@ -173,6 +173,8 @@ end -- Private Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- Add private CLASS functions here. +-- No private NAVAID functions yet. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -434,7 +436,7 @@ end -- @field #string ClassName Name of the class. -- @field #number verbose Verbosity of output. -- @field #string name Name of the point. --- @field Core.Point#COORDINATE coordinate Coordinate of the fix. +-- @field Core.Vector#VECTOR vector Position vector of the fix. -- @field Wrapper.Marker#MARKER marker Marker on F10 map. -- @field #boolean isCompulsory Is this a compulsory fix. -- @@ -477,17 +479,17 @@ NAVPOINT.version="0.0.1" -- Constructor(s) ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---- Create a new NAVPOINT class instance from a given COORDINATE. +--- Create a new NAVPOINT class instance from a given VECTOR. -- @param #NAVPOINT self -- @param #string Name Name of the fix. Should be unique! --- @param Core.Point#COORDINATE Coordinate Coordinate of the point. +-- @param Core.Vector#VECTOR Vector Position vector of the navpoint. -- @return #NAVPOINT self -function NAVPOINT:NewFromCoordinate(Name, Coordinate) +function NAVPOINT:NewFromVector(Name, Vector) -- Inherit everything from BASE class. self=BASE:Inherit(self, BASE:New()) -- #NAVFIX - self.coordinate=Coordinate + self.vector=Vector self.name=Name @@ -497,6 +499,18 @@ function NAVPOINT:NewFromCoordinate(Name, Coordinate) return self end + +--- Create a new NAVPOINT class instance from a given COORDINATE. +-- @param #NAVPOINT self +-- @param #string Name Name of the fix. Should be unique! +-- @param Core.Point#COORDINATE Coordinate Coordinate of the point. +-- @return #NAVPOINT self +function NAVPOINT:NewFromCoordinate(Name, Coordinate) + local Vector=VECTOR:NewFromVec(Coordinate) + self=NAVPOINT:NewFromVector(Name, Vector) + return self +end + --- Create a new NAVPOINT class instance from a given NAVPOINT. -- You have to specify the distance and bearing from the new point to the given point. *E.g.*, for a distance of 5 NM and a bearing of 090° (West), the -- new nav point is created 5 NM East of the given nav point. The reason is that this corresponts to convention used in most maps.