I don't have a working C compiler on my work computer, nor do I have Xlib available to me (I'm also not familiar with it, at all). That being said, given that we know our image is a square, you can do this with a single loop.
Use a simpler algorithm
The basic idea is that we know each corner of our square, and then by stepping through the length ...
The real performance issue here is fairly simple: good performance is obtained by not repeating steps. The big step that you are doing repeatedly is to figure out where the pixel goes in the output space.
If we consider @Dannano's
img[WIDTH * y + x] = 456;
We wind up doing that currently for every point. Multiplication is hard (at least classically, and ...
Write clear and concise error messages
You will notice that almost any program will not log anything when things are fine. That's desired, because you don't want to be distracted by information that is not useful. When things go wrong though, you want to get a message that explains exactly what went wrong, without overloading you with details that do not ...
Finally, I am well aware that the value of the gravitational constant 𝐺 is 6.67408×10−11 and not 0.5, as I have implemented it here; using the correct value of 𝐺 results in a simulation that runs far too slow to appreciate.
It is strange to me that you chose to change the gravitational constant rather than simply choosing a different time step; can you ...
Prefer functions and const variables over macros
While the LEN macro might be unavoidable, MIN and MAX can typically be implemented as functions. This avoids problems with side-effects, because in your macros one of the arguments is always evaluated twice.
For the constants, declare static const variables, like:
static const char *FONT = "-*-*-medium-*-*-*...
Here are some general comments and some things that may help you improve your program.
Consider whether this is the right API for you
Vulkan is a very powerful but very difficult and verbose API to use.
I find graphics programs super hard to debug so like logging everything and want the best way to do this.
If you find graphics programs super hard to debug,...
I'm not particularly knowledgeable on Rust, so this will be a light review.
I would suggest leaning on the Rust tooling quite a bit, especially when new to a language. I've heard nothing but praise for the format tool, compiler warnings, and linters.
Running the code through rustfmt only moves newlines and comments around, so good job on having a clean ...
Cool game. I enjoy code reviews when all of the code is easy to reproduce. In this case simply copying & pasting into an IDE and hitting the run button :-)
Item IMO should be renamed to GameItem, MovableGameObject or something similar. It should also be a class in it's own file, with private methods and getters, setters instead of public ...
Haven't tested if the code works. I've simply shortened the code that was given in the question.
In the code given in the question, there are variables x,x2,..x6 and y,...y6. These variables are all being used in a similar manner and a lot of code is redundant.
For instance lines like
SelectObject(hdc, CreatePen(PS_SOLID, 1, RGB(255, 0, 0)));
Welcome to Code Review , as highlighted by @MaartenBodewes's comment, the main issue of your code is that there is no reason why you don't use Java time API. My suggestions are about common things I saw repeated in your code:
ArrayList<TimeIntervalPoints> points = new ArrayList<>();
ArrayList<String> dates = getPointDates(points);
The use of classes and its member functions seems wrong to me:
Destructor should also clean up if your code throws. In case initVulkan throws, your cleanup will never be reached and you get a resource leak. Also, having a destructor makes sure that when HelloTriangleApplication app goes out of scope, i.e. when main ends, all resources are cleaned-up ...
Make sure you add #include for everything you use directly
Your code happens to compile without errors because some other header file #includes the necessary header files for you to be able to use functions like std::acos() (from <cmath>), std::abs() (from <cstdlib>), std::min() (from <algorithm>), std::unique_ptr (from <memory>), and ...
Removing unncessary branches
Looking at the assembly generated by your code, you indeed managed to get rid of all branches save for the one needed by the loop itself. Nice! But maybe you removed too many? The main issue is the speed of the loop itself. Branches outside the loop do not impact performance much, and they can actually help performance! Consider ...
In your description you mention the gravitational constant is 0.5 for performance reasons, in the code it is actually 0.1.
There are times when the this pointer is necessary, but it is not necessary in the code under review (EntryPoint.cs, Body.cs and BodySystem.cs).
To some extent this is personal ...
Comments and Observations
On code review we review working code, it is best to remove all debug code prior to posting the question on code review, so that we don't suspect the code isn't working.
Don't include code that isn't used, this is actually a bad programming practice. Of the 3 macros in the code, LEN(x), MAX(x,y) and MIN(x,y) only LEN(x) is being ...