C
C#3mo ago
michaelwplde

Cartography/imaging: understanding projection between heterogeneous 2D coordinate systems

Assumptions; the question is very agnostic to any languages or tooling, although I am approaching with CSharp and SkiaSharp specifically, but is neither here nor there concerning the core question. Which is: projecting between a world coordinate system and canvas resolution coordinates. The world coordinate system is very large, 1.5M whole numbers, represented as decimal for centimeters and fractional cm precision; neither here nor there except to understand the A coordinate system. The B coordinate space of course is the target bitmap, in whatever resolution, may be 8K, 16K even 32K, bandwidth and memory permitting, square. Thus far the naive attempt is to apply a simple world per bitmap ratio, or pixels per world, depending upon the point or rectangle bounds conversion. But there is always an error. Example image: the circle and points are accurate relative to themselves; but are inaccurate to the target bitmap in question, the scaling being something like 183 units per px error involved applying any ratios to the source coordinates. This error can vary depending on the source bitmap resolution, of course. So the algorithm should be robust keeping that in mind. Overall, my goal is to gain the understanding, calculations involved, to do the projection more precisely regarding world to canvas, without the sort of translation issues. And adapt that into the implementation details.
No description
7 Replies
michaelwplde
michaelwpldeOP3mo ago
I was curious and ran it through for some GPT feedback. I am not hundred percent convinced this algorithm would necessarily provide the t I want; owing to the fact, the scaling factor is something like 1/183 px/world, and that it seems as though X-Y the error is cumulatively increasing over that range; even more strange orthogonal to the distance the further Y-X travel from canvas zero. https://math-gpt.org/3379928b-c8c1-4712-8a8f-43f6ed14205a
MathGPT | AI Math Solver & Calculator
MathGPT is an ai math solver, integral calculator, derivative calculator, polynomial calculator, and more! Upload a photo and solve your math homework!
michaelwplde
michaelwpldeOP3mo ago
That's 1/183 assuming 1.5M world coordinate system (hard fact) versus 8192x bitmap canvas. Of course factors vary depending upon the bitmap resolution; I can start from as much as approximately ~64Kx if necessary, but that gets expensive to SKIA, etc.
canton7
canton73mo ago
From first glance, sounds like a rounding/truncation error in your conversion?
michaelwplde
michaelwpldeOP3mo ago
That's exactly what's going on. How do I contend with that? Rounding issues beyond 6 places is not acceptable, especially in this scenario. Contingencies at my disposal are to start from larger resolution image source, but the performance hit is huge. Windows Calculator reports 8192 / 1500000 being 0.00546448087431693989071038251366, which I need every single digit from that ratio for precision to be what we want, whereas dotnet csharp reporting more like 0.0054613333333333337, give or take depending decimal, float, etc, but all losing their stuff after about six places.
canton7
canton73mo ago
How exactly are you doing the scaling? double should be good up to about 15 significant figures, decimal significantly beyond that (28-29) If I do that division in windows calculator, I get 0.00546133333333333333333333333333, which exactly matches what I get from C#
MODiX
MODiX3mo ago
canton7
REPL Result: Success
Console.WriteLine(8192.0f / 1500000.0f);
Console.WriteLine(8192.0 / 1500000.0);
Console.WriteLine(8192m / 1500000m);
Console.WriteLine(8192.0f / 1500000.0f);
Console.WriteLine(8192.0 / 1500000.0);
Console.WriteLine(8192m / 1500000m);
Console Output
0.0054613333
0.005461333333333334
0.0054613333333333333333333333
0.0054613333
0.005461333333333334
0.0054613333333333333333333333
Compile: 428.124ms | Execution: 36.436ms | React with ❌ to remove this embed.
canton7
canton73mo ago
So I'm not sure where you got 0.00546448087431693989071038251366 from. It's exactly 1/183, if that helps narrow it down
Want results from more Discord servers?
Add your server