Skip to content

Conversation

@le-sigwal
Copy link
Contributor

@godardma
Copy link
Contributor

Hello and thank you for your PR.

Would it please be possible for you to provide a small example to highlight the change brought by this PR ? Also a small explanation of the code could help us.

In complement, I noticed that you introduced some tags in the code (here "//>[VBS_VR_000004]"). I guess that these tags refer to your personal data base. As VIBes is a collaborative tool hosted on github would it be possible to avoid these tags or to use github-related tags instead ?

@le-sigwal
Copy link
Contributor Author

Just added PR reference in commit.

To have "Axis Equal" aspect ratio, a length in axis unit must correspond to the same length in pixel along x and y axis.
In other words, the height to width ratio must be same in axis unit [au] and in pixel [px].

vbs_rs_000002_aspect-ratio

Here is the use-case:

#include "vibes.h"

int drawpolygon_vib_xpl(){

	vibes::beginDrawing();               // <Initializes the Vibes "connection"
	vibes::newFigure("drawpolygon_vib"); // <Creates a new Vibes figure

	vibes::newGroup("Du Gwer", /*"black[green]"*/"k[g]");
	vibes::newGroup("Goz Treuz", "black[transparent]");
	vibes::newGroup("Du Melen", /*"black[yellow]"*/"#000000[#FFFF00]");
	vibes::newGroup("Du Glaz", "black[blue]");
	vibes::newGroup("Du Ruz", "black[red]");

	double e=1, xd=7*e, xd_2=xd/2, yd_2=e/*, yd=2.0*yd_2*/;

	std::vector<double> x0, y0;
	x0.push_back(  xd_2);       y0.push_back( 0);
	x0.push_back(  xd_2-yd_2);  y0.push_back( yd_2);
	x0.push_back(-(xd_2-yd_2)); y0.push_back( yd_2);
	x0.push_back(- xd_2);       y0.push_back( 0);
	x0.push_back(-(xd_2-yd_2)); y0.push_back(-yd_2);
	x0.push_back(  xd_2-yd_2);  y0.push_back(-yd_2);
	x0.push_back(  xd_2);       y0.push_back( 0);
	vibes::drawPolygon(x0, y0, vibes::Params("group","Du Gwer"));

	std::vector<double> x1, y1;
	x1.push_back(  xd_2);       y1.push_back( 0);
	x1.push_back(  xd_2+yd_2);  y1.push_back( yd_2);
	x1.push_back(  xd_2+yd_2);  y1.push_back( yd_2+(xd-2*e));
	x1.push_back(  xd_2);       y1.push_back( yd_2+(xd-e));
	x1.push_back(  xd_2-yd_2);  y1.push_back( yd_2+(xd-2*e));
	x1.push_back(  xd_2-yd_2);  y1.push_back( yd_2);
	x1.push_back(  xd_2);       y1.push_back( 0);
	vibes::drawPolygon(x1, y1, vibes::Params("group","Goz Treuz"));

	std::vector<double> x2, y2;
	x2.push_back(  xd_2);       y2.push_back( 0 +yd_2+(xd-e));
	x2.push_back(  xd_2-yd_2);  y2.push_back( yd_2+yd_2+(xd-e));
	x2.push_back(-(xd_2-yd_2)); y2.push_back( yd_2+yd_2+(xd-e));
	x2.push_back(- xd_2);       y2.push_back( 0 +yd_2+(xd-e));
	x2.push_back(-(xd_2-yd_2)); y2.push_back(-yd_2+yd_2+(xd-e));
	x2.push_back(  xd_2-yd_2);  y2.push_back(-yd_2+yd_2+(xd-e));
	x2.push_back(  xd_2);       y2.push_back( 0 +yd_2+(xd-e));
	vibes::drawPolygon(x2, y2, vibes::Params("group","Du Melen"));

	std::vector<double> x3, y3;
	x3.push_back(  xd_2     -xd);  y3.push_back( 0);
	x3.push_back(  xd_2+yd_2-xd);  y3.push_back( yd_2);
	x3.push_back(  xd_2+yd_2-xd);  y3.push_back( yd_2+(xd-2*e));
	x3.push_back(  xd_2     -xd);  y3.push_back( yd_2+(xd-e));
	x3.push_back(  xd_2-yd_2-xd);  y3.push_back( yd_2+(xd-2*e));
	x3.push_back(  xd_2-yd_2-xd);  y3.push_back( yd_2);
	x3.push_back(  xd_2     -xd);  y3.push_back( 0);
	vibes::drawPolygon(x3, y3, vibes::Params("group","Du Glaz"));

	std::vector<double> x4, y4;
	x4.push_back(  xd_2     -xd);  y4.push_back( 0            -xd);
	x4.push_back(  xd_2+yd_2-xd);  y4.push_back( yd_2           -xd);
	x4.push_back(  xd_2+yd_2-xd);  y4.push_back( yd_2+(xd-2*e)-xd);
	x4.push_back(  xd_2     -xd);  y4.push_back( yd_2+(xd-e)-xd);
	x4.push_back(  xd_2-yd_2-xd);  y4.push_back( yd_2+(xd-2*e)-xd);
	x4.push_back(  xd_2-yd_2-xd);  y4.push_back( yd_2           -xd);
	x4.push_back(  xd_2     -xd);  y4.push_back( 0            -xd);
	vibes::drawPolygon(x4, y4, vibes::Params("group","Goz Treuz"));

	std::vector<double> x5, y5;
	x5.push_back(  xd_2);       y5.push_back( 0 -yd_2-(xd-e));
	x5.push_back(  xd_2-yd_2);  y5.push_back( yd_2-yd_2-(xd-e));
	x5.push_back(-(xd_2-yd_2)); y5.push_back( yd_2-yd_2-(xd-e));
	x5.push_back(- xd_2);       y5.push_back( 0 -yd_2-(xd-e));
	x5.push_back(-(xd_2-yd_2)); y5.push_back(-yd_2-yd_2-(xd-e));
	x5.push_back(  xd_2-yd_2);  y5.push_back(-yd_2-yd_2-(xd-e));
	x5.push_back(  xd_2);       y5.push_back( 0 -yd_2-(xd-e));
	vibes::drawPolygon(x5, y5, vibes::Params("group","Du Ruz"));

	std::vector<double> x6, y6;
	x6.push_back(  xd_2     );  y6.push_back( 0            -xd);
	x6.push_back(  xd_2+yd_2);  y6.push_back( yd_2           -xd);
	x6.push_back(  xd_2+yd_2);  y6.push_back( yd_2+(xd-2*e)-xd);
	x6.push_back(  xd_2     );  y6.push_back( yd_2+(xd-e)-xd);
	x6.push_back(  xd_2-yd_2);  y6.push_back( yd_2+(xd-2*e)-xd);
	x6.push_back(  xd_2-yd_2);  y6.push_back( yd_2           -xd);
	x6.push_back(  xd_2     );  y6.push_back( 0            -xd);
	vibes::drawPolygon(x6, y6, vibes::Params("group","Du Glaz"));

	/*vibes::axisAuto("drawpolygon_vib");*/
	vibes::axisEqual("drawpolygon_vib");
	vibes::axisLabels("[m]", "[m]", "drawpolygon_vib");
	vibes::saveImage("./drawpolygon_vib.svg");

	vibes::endDrawing(); // <Closes the Vibes "connection"

	return 0;
}

Use-case with correction:
vbs_vr_000004-verified

@le-sigwal le-sigwal closed this Jul 1, 2025
@le-sigwal le-sigwal reopened this Jul 1, 2025
@godardma
Copy link
Contributor

godardma commented Jul 2, 2025

Hello,

Thank you for your explanation and for the use-case. I tried to pull your changes to test the modification but it seems that the method "axisEqual" does not exist (i.e. it is not in vibes.cpp and vibes.h). Did you add it on your side for the use case to work ?

Also thank you for changing the tag to the PR ID. I noticed that there are some "VBS_VR_000002" tags left from your last PR, would it be possible to do the same with these ?

@le-sigwal
Copy link
Contributor Author

Just commited AxisEqual method in C++ API (but not tested).

Happy birthday Vibes! 🤗

@le-sigwal
Copy link
Contributor Author

figureTest (all_commands.cpp) with axisEqual
vibes_test

@godardma
Copy link
Contributor

godardma commented Jul 4, 2025

It's OK for me, can I merge the PR ?

@le-sigwal
Copy link
Contributor Author

The PR can be merged yes.
As a piece of information, I'm analysing the way to have axis Equal on resize too for a next PR.

@godardma godardma merged commit 544e792 into ENSTABretagneRobotics:master Jul 7, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants