Jump to content

pqsController.GetSurfaceHeight


Recommended Posts

2 minutes ago, Xyphos said:

The coordinate system goes from -180 to 180 for latitude and longitude

I'll take a look at your source when I next sit down at my system ... shouldn't be too hard to figure out what is wonky

Link to comment
Share on other sites

@Xyphos So took a look and I would approach it is as follows:

Add in a min latitude and longitude and set them to -180 ... set the max to 180 or you can just have a local variable in DoScan that you add 0.001 to and when it reaches 360 DoScan ends
In the button function that triggers DoScan set those values again to be -180 (this is to force them to reset back to the starting values before the scan commences)
Then iterate through the both of them in the DoScan coroutine like you are already doing

This should solve your issue with little code needing to be changed .. That is unless I am misunderstanding what the problem is :rolleyes:

 

Edited by DoctorDavinci
Link to comment
Share on other sites

well, I fixed the code and it works... very... very... very... slowly.
I didn't account for the time it takes to complete 360 * 1000 * 180 * 1000 operations by doing them 100 times per physics frame

so... would it be possible to speed things up with multiple coroutines? is there a limit as to how many are allowed?

possible idea: maybe do a preliminary fast and less accurate scan to find regions with height > 100 (or 1000?) and deep scan within those regions
but this could be erroneous if the fast scan doesn't register a peak near the scan point...

 

I'm open to ideas.

Edited by Xyphos
Link to comment
Share on other sites

Just now, Xyphos said:

well, I fixed the code and it works... very... very... very... slowly.
I didn't account for the time it takes to complete 360 * 1000 * 180 * 1000 operations by doing them 100 times per physics frame

so... would it be possible to speed things up with multiple coroutines? is there a limit as to how many are allowed?

possible idea: maybe do a preliminary fast and less accurate scan to find regions with height > 100 (or 1000?) and deep scan within those regions
but this could be erroneous if the fast scan doesn't register a peak near the scan point...

 

I'm open to ideas.

Running multiple coroutines at once to handle everything will likely end up being somewhat convoluted but is doable ... although it would still take awhile

Perhaps instead of doing the whole planet at once you could use the GPS pos of the satellite and give it a scanning radius  from that point on the surface of the planet being scanned

Coordinates are the same in orbit as on the surface, only difference is the altitude ... that and precision as the meters per degree of circumference increases with the radius of the sphere

Here's some code that will let you calculate how many meters are in a degree of any given planet and then break that down into how many degrees are in a meter in relation to the current celestial body ... use it the same way as the PQS deal I showed you, just with a celestial body being passed instead of latitude and longitude

It will give you how many degrees are in a meter at 0 meters in altitude (the radius of the celestial body) ... you can even add the current vessels altitude to get more precision if you're high in the sky or way out in orbit, but for your purposes it should do what you would need

Quote

        public double GetDegreesPerMeter(CelestialBody _body)
        {
            double mPerDegree = (((2 * _body.Radius) * Math.PI) / 360);
            return 1 / mPerDegree;
        }

 

Use the above to get how many degrees are in a meter at 0 altitude and then multiply that by the scan radius you want (in meters) and then your max and min latitudes and longitudes just need to be corrected with the offset before you start the scan

 

Link to comment
Share on other sites

2 hours ago, DoctorDavinci said:

Here's some code that will let you calculate how many meters are in a degree of any given planet and then break that down into how many degrees are in a meter in relation to the current celestial body ...
It will give you how many degrees are in a meter at 0 meters in altitude (the radius of the celestial body) ... you can even add the current vessels altitude to get more precision if you're high in the sky or way out in orbit, but for your purposes it should do what you would need

 

this might actually help. thanks!

a landing zone could be like,  25 square meters so all I have to do is calculate the degrees for those areas and reduce the number of scans overall.

Edited by Xyphos
Link to comment
Share on other sites

okay, so even with that piece of code added it's still very slow.
too slow to be an ACTIVE scan, so I'm changing plans yet again.
I'll revert back to the original concept, run it from the tracking station as an addon instead of a part module, scan all bodies and log the results to a .cfg file as a data cache
if I let my computer run for a week, I should have generated the cache data to be distributed with the mod, and used with a separate science experiment part module.
the science experiment should read the cached data and return the highest peak almost instantly, complete with a waypoint.
the upside is, celestial body data hasn't changed since I don't know when so I won't have to regenerate the cached data often.
the downside to this is, only stock planets would have the cached data and any mod systems would have to have the cached data generated from the space center before the science experiment could work.

unless anyone has any other ideas?

Edited by Xyphos
Link to comment
Share on other sites

  • 2 weeks later...

progress update.
I took a break from development over the holiday but today I've made some changes to the code. It's still too slow to scan actively, so the cache data generator is working from the tracking station, and the part module will use the cache data to provide near-instant results. The cache data is accurate within 20 square meters, I figure that should be a large enough area to quickly skip scanning over without greatly decreasing scan accuracy.

5iCZkTT.png

 

As soon as the cache data is completed, I'll be ready to further develop the part module and waypoint code.

Edited by Xyphos
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...