Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Addons > Addon Requests
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Addon Requests If you have a request for a new addon or want to know where to find a specific addon, ask it here!

Reply
 
Thread Tools
Old 03-21-2017, 12:45 PM   #76
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 Thanks.

So if we get this:
Code:
VECTOR3 rpos, rvel;
            oapiGetRelativePos(hvessel, GetHandle(), &rpos);
            double distance = length(rpos);
            oapiGetRelativeVel(hvessel, GetHandle(), &rvel);
if dotp(&rvel, &rpos) < 0 so the vessel is travelling towards the center, right?
No, it is "dotp(rvel, rpos)" and yes, coarsely towards the center. dotp(rvel, rpos) = 0 would mean tangential travel. in this case, "dotp(rvel, rpos)/distance" is the range rate.

There are also other mathematical solutions possible, but dotp should become a name you should remember. It is really helpful mathematics.

And for being annoying: "&rvel" means "a pointer/reference to the variable rvel", for doing a classic "call by reference" (An other name you should better look up in a calm moment and learn, its useful). You need when you have a variable and need a pointer to it.

Last edited by Urwumpe; 03-21-2017 at 12:48 PM.
Urwumpe is online now   Reply With Quote
Old 03-21-2017, 12:59 PM   #77
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Ok So if dotp(rvel, rpos) = 0 we are travelling toward the center? So is x, y a factor. Can we make a larger target
gattispilot is online now   Reply With Quote
Old 03-21-2017, 01:21 PM   #78
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 Ok So if dotp(rvel, rpos) = 0 we are travelling toward the center? So is x, y a factor. Can we make a larger target
No, tangential means your velocity vector is perpendicular to the position vector.
Urwumpe is online now   Reply With Quote
Thanked by:
Old 03-21-2017, 01:37 PM   #79
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

So dotp(rvel, rpos) = 0 means travelling toward the center, right?

But we have to be perpendicular to the gate, right? So the x and Y difference would be 0
gattispilot is online now   Reply With Quote
Old 03-21-2017, 01:50 PM   #80
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 So dotp(rvel, rpos) = 0 means travelling toward the center, right?

But we have to be perpendicular to the gate, right? So the x and Y difference would be 0
Again. No. By repeating it, it does not get better.

dotp(A, B) = 0 means, A is 90 to B, which means perpendicular.

And why should you travel perpendicular to the gate? Its like crossing a like by walking parallel to it. It makes no sense.



Read here for the mathematical background:

https://en.wikipedia.org/wiki/Dot_product

What we are exploiting here can be visualized as such:



But instead of normalizing the position vector for accurate results, we just want the sign to show the coarse trend. Does the velocity point towards or away from the gate?
Urwumpe is online now   Reply With Quote
Old 03-21-2017, 02:04 PM   #81
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

oK. if we use the gate example. I would walk perpendicular to the opening. parallel would along the side of it.


Last edited by gattispilot; 03-21-2017 at 02:12 PM.
gattispilot is online now   Reply With Quote
Old 03-21-2017, 02:12 PM   #82
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 oK. if we use the gate example. I would walk perpendicular to the opening. parallel would along the side of it.
No.

If you would describe the gate as plane, yes, a perpendicular would bring you to it.

But now... how do you describe planes in code? The common mathematical way is using a normal vector, which already rests per definition perpendicular to this plane. for example, in your previous example, you say "The normal vector of my plane is the Z axis in relative coordinates." You might not have notice that you said so, but that is what you describe in the code in a geometrical form. (You might remember normal and anti-normal in Orbiter and KSP regarding the orbit plane)

So, if you move perpendicular to the normal vector, you are moving parallel to the plane. If you move parallel to the normal vector, you are moving perpendicular to the plane.

(Yes, if you have a proper normalized normal vector for the plane, the dot product dotp(normal, velocity) gives you the velocity away or towards the plane.)

Last edited by Urwumpe; 03-21-2017 at 02:23 PM.
Urwumpe is online now   Reply With Quote
Thanked by:
Old 03-21-2017, 02:35 PM   #83
gattispilot
Addon Developer
 
gattispilot's Avatar
Default



So:
the dot product dotp(normal, velocity) gives you the velocity away or towards the plane.)

Code:
dotp(rpos, rvel)
gives velocity away or towards.
gattispilot is online now   Reply With Quote
Old 03-21-2017, 02:41 PM   #84
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 

So:
the dot product dotp(normal, velocity) gives you the velocity away or towards the plane.)

Code:
dotp(rpos, rvel)
gives velocity away or towards.
Not that simple: Again: rpos should be normalized to length 1 for this to be correct, or you would have to divide the result by the length of rpos.

The formula works for a few cases. For example, you could treat rpos as radius vector, then it is the velocity away or towards a sphere.
Urwumpe is online now   Reply With Quote
Thanked by:
Old 03-21-2017, 02:48 PM   #85
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

I hope some one update the code.

I guess it would be too easy to get the vessel position and the gateway. compare the x, y, z and if within a value execute the move?
gattispilot is online now   Reply With Quote
Old 03-21-2017, 02:54 PM   #86
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 I hope some one update the code.

I guess it would be too easy to get the vessel position and the gateway. compare the x, y, z and if within a value execute the move?
Why? It is easy.

The problem is: You need to prevent that after jumping from Gate A to Gate B, Gate B jumps you back to Gate A, etc.

For that you should have a definition that makes sure, movement away from the gate is ignored.

That is all.
Urwumpe is online now   Reply With Quote
Thanked by:
Old 03-21-2017, 03:09 PM   #87
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Quote:
Originally Posted by Urwumpe View Post
 Why? It is easy.

The problem is: You need to prevent that after jumping from Gate A to Gate B, Gate B jumps you back to Gate A, etc.

For that you should have a definition that makes sure, movement away from the gate is ignored.

That is all.
Easy for you not me

But wouldn't you just look at the z difference to see if you were heading towards or away.
gattispilot is online now   Reply With Quote
Old 03-21-2017, 03:15 PM   #88
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 Easy for you not me

But wouldn't you just look at the z difference to see if you were heading towards or away.
Which "z difference"?
Urwumpe is online now   Reply With Quote
Old 03-21-2017, 03:28 PM   #89
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Z position of vessel and z position gateway. I guess you could store a reading and if the next reading was less then the vessel is moving closer
gattispilot is online now   Reply With Quote
Old 03-21-2017, 03:38 PM   #90
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 Z position of vessel and z position gateway. I guess you could store a reading and if the next reading was less then the vessel is moving closer
Why?
Urwumpe is online now   Reply With Quote
Reply

  Orbiter-Forum > Orbiter Addons > Addon Requests


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 09:57 PM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.