GDI + / Direct2D Graphics and World Size

I am migrating an outdated CAD application to .NET. Its graphical requirements are not very complicated, and GDI + with some optimizations has good performance if you are not doing any fancy things. However, I will also support Direct2D, as it offers the best experience and performance.

My problem is that old applications support Mercator coordinates, and they just don't fit into the float, so app and GDI + crashes don't go well with extreme translational conversions. I see that Direct2D also uses float.

So I have to implement a custom matrix for this to translate, etc. to screen coordinates? Is there any other solution?

+5
source share
2 answers

Perhaps this library may help in your porting efforts:

https://github.com/NetTopologySuite/NetTopologySuite

This is the JTS (Java Topology Suite) port, which includes geometry / gis-related functionality.

The GeoAPI.NET project (part of NetTopologySuite) provides basic geometry classes, coordinate systems, and much more.

Take a look at this Coordinate class, where their fields X, Y, and Z are double precision .:

https://github.com/NetTopologySuite/GeoAPI/blob/master/GeoAPI/Geometries/Coordinate.cs

+1
source

Both GDI + and Direct2D use floats.

Duplicate graphics cards exist , but you can NOT use this through GDI + or Direct2D

I see several boot options for using GDI + / Direct2D depending on the required speed and accuracy:

  • Download data by doubling and scaling / converting to floats immediately after loading. This allows you to use all the functions of GDI +, Direct2D and any associated libraries for model management (rotation, scaling, translation, ...). The disadvantage is that the model loses accuracy before transformations.

  • Download data using doubling, do all the manipulations using doubling and scaling / convert to float just before rendering. Disadvantage: you need to find or write a library that uses duplicates for data management, and you cannot use the GPU for manipulation. Positive: Accuracy lasts longer and can be critical to your data.

First I will try option 1, as it is easier (more standard graphical programming). Only when the accuracy is insufficient will I try option 2.

I have no experience using / precision programming API with double precision, maybe someone else will add this as an answer.

An interesting discussion about two-locale / floating can be found here based on this discussion. I strongly recommend that you first try to find out if you need double precision, as in the end it will be displayed on the screen with only one precision.

+1
source

Source: https://habr.com/ru/post/1203953/


All Articles