- Joined
- Mar 28, 2008
- Messages
- 666
- Reaction score
- 20
- Points
- 33
Hello,
i plan to creat and public a class for orbiter with basic and advanced functions / methods witch are often needed by add ons developers.
Let's say thats only the first step, the next step will be to implement some of these functions to an extended vessel class.
For example, so you can say later
So here is the first look:
Now in the code, you can say for examle:
Sure, this is a verry primitiv example!
What do you think about a open library for add on develppers like this?
Or is there allready somethink like this?
What are yours reqired functions (with solution if possible) you often need?
i plan to creat and public a class for orbiter with basic and advanced functions / methods witch are often needed by add ons developers.
Let's say thats only the first step, the next step will be to implement some of these functions to an extended vessel class.
For example, so you can say later
Code:
VESSEL->GetBaseDownrange(OBJHANDLE hBase);
Code:
// (c) This code is released under the terms of the GNU 1.3 or later.
// see: http://www.gnu.org
#ifndef orbiterMath_h
#define orbiterMath_h
#include <orbitersdk.h>
// Basic math funktion for Orbiter
class ORBITERMATH
{
private:
class SURFACEPOS
{
public:
bool setPos(double lat,double lng);
//Set the position of a SURFACEPOS Object direct (in RAD) for calculations
bool setPos(OBJHANDLE hobj);
//Set the position of a SURFACEPOS Object direct (in RAD) for calculations
bool setPos(OBJHANDLE hobj, OBJHANDLE href);
/*
Set the position of an object on the surface of href.
A planet (OBJHANDLE) is required for distance calculaions,
where the radius of the Planet is needed.
*/
bool setBasePadPos(OBJHANDLE hBase, int basePadID);
// Set the position of a VTOL Landing pad for calculations.
bool setPos(VESSEL* V);
// Set the Position of a "Vesselpointer" object for calculations
double getLat();
// Returns the lattitude of the set object
double getLng();
// Returns the longtitude of the set object
private:
bool checkSurfaceLatLong(double lat,double lng);
//Not created yet
double plat;
double plng;
double prad;
};
public:
double getRadFromGrad(double Grad);
//Not created yet
double getGradFromRad(double Grad);
//Not created yet
class DISTANCE
{
public:
static double getLinearDistance(OBJHANDLE hObj1, OBJHANDLE hObj2);
// Returns the direct distance between two OBJHANDLE - objects in meter
static double getSurfaceDownrange(OBJHANDLE hObj1, OBJHANDLE hObj2);
// Returns the downrange (way over surface) between to OBJHANDLE - objects in meter
static double getSurfaceDownrangeToPad(VESSEL *V, OBJHANDLE hBase, int padID);
/* Returns the downrange (way over surface) between a Vessel and a basepad in meter
Errorvalues (TODO):
- -1: if hbase is no a base handle
- -2: if Vessels reference body is different to the base planet
*/
private:
static double getBaseReferenceRadius(OBJHANDLE hBase);
//Returns the radius of the planet where the base is being
static double getDownrangeBetweenSetObjects(SURFACEPOS *surfacepos1, SURFACEPOS *surfacepos2,double radiusRefPlanet);
//Returns the downrange between two set surfacepos object
};
class DIRECTION
{
public:
static double GetSurfaceDirection(OBJHANDLE hObjFrom, OBJHANDLE hObjTo);
static double GetSurfaceDirection(OBJHANDLE hObjFrom, OBJHANDLE hObjTo, bool inGRAD);
/* Returns the direction between two Objects in rad or degrees (degrees is inGRAD is set to true)
Errorvalues (TODO):
- -1: if hbase is no a base handle
- -2: if Vessels reference body is different to the base planet
*/
static double GetSurfaceBasePadDirection(VESSEL *V, OBJHANDLE hBase, int basePadID);
static double GetSurfaceBasePadDirection(VESSEL *V, OBJHANDLE hBase, int basePadID, bool inGRAD);
/* Returns the direction between a vessel and a basepad (hbase + pasepad ID) in rad or degrees (degrees is inGRAD is set to true)
Errorvalues (TODO):
- -1: if hbase is no a base handle
- -2: if Vessels reference body is different to the base planet
- -3: if basePad ID > oapiGetBasePadCount(hBase)
*/
private:
static double CalcDirectionBetweenSetObjects(SURFACEPOS *surfacepos1, SURFACEPOS *surfacepos2);
};
};
#endif
Now in the code, you can say for examle:
Code:
#define ORBITER_MODULE
#include "orbitersdk.h"
#include "orbitermath.h"
DLLCLBK void opcPostStep (double ENow, double simdt, double mjd)
{
OBJHANDLE hV1 = oapiGetVesselByName("GL-NT");
OBJHANDLE hBase = oapiGetBaseByName(oapiGetGbodyByName("Moon"),"Brighton Beach");
char baseName[255];
oapiGetObjectName(hBase,baseName,255);
sprintf(oapiDebugString(),"The downrange between GL-NT and Brighton Beach is: %f",ORBITERMATH::DISTANCE::getSurfaceDownrange(hV1,hBase));
}
Sure, this is a verry primitiv example!
What do you think about a open library for add on develppers like this?
Or is there allready somethink like this?
What are yours reqired functions (with solution if possible) you often need?
Last edited: