Skip to content

math: add tests for vec2,3,4 perpendicular#25840

Merged
spytheman merged 16 commits into
vlang:masterfrom
Linklancien:fix-perpendicular
Nov 30, 2025
Merged

math: add tests for vec2,3,4 perpendicular#25840
spytheman merged 16 commits into
vlang:masterfrom
Linklancien:fix-perpendicular

Conversation

@Linklancien

@Linklancien Linklancien commented Nov 27, 2025

Copy link
Copy Markdown
Contributor

This PR fix an issue cause because of the change of the project function

It also add some test to assure that won't happend again

@Linklancien

Copy link
Copy Markdown
Contributor Author

It may conflict with #25841 because of the inversion of u and v

@tankf33der

Copy link
Copy Markdown
Contributor

I am firmly certain that this PR is suspicious.

@Linklancien
project() is incorrect itself for vec2,3,4.

@Linklancien Linklancien marked this pull request as draft November 27, 2025 16:21
@Linklancien

Copy link
Copy Markdown
Contributor Author

The main issue I wanted to fix was to introduce a tests for the the perpendicular function to avoid regressions

@Linklancien Linklancien changed the title math: fix vec2,3,4 perpendicular issue caused because of project fix math: add tests for vec2,3,4 perpendicular Nov 27, 2025
@tankf33der

Copy link
Copy Markdown
Contributor

@Linklancien

Our perpendicular() is correct. Proof is below:

namespace glm
{
	template<typename genType>
	GLM_FUNC_QUALIFIER genType perp(genType const& x, genType const& Normal)
	{
		return x - proj(x, Normal);
	}
}//namespace glm

@Linklancien

Copy link
Copy Markdown
Contributor Author

@Linklancien

Our perpendicular() is correct. Proof is below:

namespace glm
{
	template<typename genType>
	GLM_FUNC_QUALIFIER genType perp(genType const& x, genType const& Normal)
	{
		return x - proj(x, Normal);
	}
}//namespace glm

Yes it is
It just lack tests

@spytheman

spytheman commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

This PR does not pass its tests either before or after rebasing on #25841 (which is now merged).

Imho there is a bug somewhere.

Comment thread vlib/math/vec/vec3_test.v Outdated
@Linklancien Linklancien marked this pull request as ready for review November 28, 2025 15:10
@Linklancien

Copy link
Copy Markdown
Contributor Author

Thoses push should be good and only add test for perpendicular

@JalonSolov

Copy link
Copy Markdown
Collaborator

You need to v fmt your tests.

@Linklancien

Copy link
Copy Markdown
Contributor Author

Oh no

@Linklancien

Copy link
Copy Markdown
Contributor Author

I forgot to fmt

Comment thread vlib/math/vec/vec3_test.v Outdated
Comment thread vlib/math/vec/vec4_test.v Outdated
@JalonSolov

Copy link
Copy Markdown
Collaborator

Something useful if you're working on V itself...

From CONTRIBUTING.md:

3.1 (optional) Run these commands, which ensure that all your code will be
automatically formatted, before committing:

cp cmd/tools/git_pre_commit_hook.vsh .git/hooks/pre-commit
chmod 755 .git/hooks/pre-commit

@JalonSolov

Copy link
Copy Markdown
Collaborator

Side note: Perhaps that pre-commit trigger should be set by default in the V repo. Would solve this particular "headache" for new people, and perhaps help some not-so-new.

@spytheman

Copy link
Copy Markdown
Contributor

Side note: Perhaps that pre-commit trigger should be set by default in the V repo. Would solve this particular "headache" for new people, and perhaps help some not-so-new.

how? should it be put in the makefiles?

@Linklancien

Copy link
Copy Markdown
Contributor Author

Something useful if you're working on V itself...

From CONTRIBUTING.md:

3.1 (optional) Run these commands, which ensure that all your code will be
automatically formatted, before committing:

cp cmd/tools/git_pre_commit_hook.vsh .git/hooks/pre-commit
chmod 755 .git/hooks/pre-commit

I did read that but didn't understand where to execute the command even if it seemed really usefull

@spytheman

Copy link
Copy Markdown
Contributor

I am using the git hook for several years at this point daily, so I guess it is stable enough (I only occasionally have to pass --no-verify to git commit to skip it, when debugging issues in vfmt itself, but most people will not have to debug vfmt itself) 🤔 .

@spytheman

spytheman commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

I did read that but didn't understand where to execute the command even if it seemed really usefull

It has to be done in a shell where you have done cd /root/of/your/V_repo once.
I.e. you have to be in the top level folder, that contains the .git folder for the V repository.

@JalonSolov

Copy link
Copy Markdown
Collaborator

Side note: Perhaps that pre-commit trigger should be set by default in the V repo. Would solve this particular "headache" for new people, and perhaps help some not-so-new.

how? should it be put in the makefiles?

That would be one way, for certain.

Comment thread vlib/math/vec/vec2_test.v Outdated
Comment thread vlib/math/vec/vec4_test.v Outdated
Comment thread vlib/math/vec/vec3_test.v Outdated

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me now, and it is ready to be merged.

@tankf33der what do you think?

Comment thread vlib/math/vec/vec2.v Outdated

@tankf33der tankf33der left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main thing is that our perpendicular() function is correct and new tests never hurt.

@tankf33der

Copy link
Copy Markdown
Contributor

@spytheman lets merge.

@spytheman

Copy link
Copy Markdown
Contributor

Thank you @Linklancien 🙇🏻 .
Thank you @tankf33der 🙇🏻 .

@spytheman spytheman merged commit a8a5e80 into vlang:master Nov 30, 2025
80 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.

4 participants