Comments (9)
@astronouth7303 Is that supposed to be the projection of a
on the surface normal to b
?
'cause that wouldn't be it, I think.
Anyhow, yes, having a projection method seems reasonable to me.
from ppb-vector.
No, that would be the projection of a
onto the vector b
, not its normal, as per wikipedia.
Although maybe defining a version that operates on the normal make sense? Matches reflect then?
from ppb-vector.
@astronouth7303 Both make sense:
- if we think of projecting and reflecting on surfaces (which makes extra sense in higher dimensions), we definitely want a normal;
- if we think of projecting and reflecting on a line, defining it by a collinear vector also makes sense.
I guess we could have project_by
(for the projection on a vector's normal) and project_unto
(the vector's collinear line), and similarly reflect_by
and reflect_unto
(and deprecate reflect
, as the name is ambiguous). The method names are just a placeholder proposal, I didn't think deeply about it and there might be better choices.
If that's something we agree on, I'd be happy to make it happen.
from ppb-vector.
Higher dimensions is something that's explicitly out of scope?
from ppb-vector.
@astronouth7303 This was a parenthesis specifically because of that; interpret that point as βit's an API which is sensible in 2D, and is the main thing you would want in 3Dβ.
I don't think it's out-of-scope to provide an API that's consistent with what happens in not-2D geometry (lowering cognitive load on users).
from ppb-vector.
@pathunstrom any perspective from the teaching/student side?
from ppb-vector.
I'm going to ask around, but first thoughts:
reflect
is there because it's an algorithm I used regularly for physics based games (like Arkanoid clones). I've never needed reflect across a line. So my thought on that is Vector.reflect
should be the physics based version, and something like Vector.reflect_across
for the across a line version. (Also I'd prefer reflect_onto
over reflect_unto
but neither of those feel accurate to me.)
EDIT: Thinking about this further, is there that much of a difference between these two? Add a keyword argument to handle the offset that defaults to the null vector and the mechnics of both are the same? (Correct me if I'm wrong, please.)
I need to dig more into projection, another thing I've never needed so need to understand better before I can comment.
from ppb-vector.
I realized we might need it because @\eevee was discussing some physics they were doing and one of the steps involved projecting the momentum onto the ground. (They were dealing with momentum going over a hill causing the character to catch some air.)
from ppb-vector.
That's a good enough reason to add some kind of projection method, so good even if I don't grok it yet.
from ppb-vector.
Related Issues (20)
- Improve docstrings & type signatures HOT 1
- Move CI away from Travis HOT 1
- Falky tests HOT 1
- Cirrus CI: The allow_failure parameter is incorrect HOT 1
- Implement __new__ to avoid needless copies
- Re-enable test_object_size on CPython 3.8 and later HOT 1
- lint.sh should check that requirements are fulfilled
- Make Vector hashable HOT 8
- Drop Py3.6 support? HOT 12
- Fix FreeBSD
- Add pattern matching support HOT 2
- Addition too strict
- Round all calculations like in rotate HOT 5
- Update __repr__
- Add type hinting HOT 1
- Add __neg__ HOT 3
- Add property-based testing HOT 4
- Testing parameter names should be improved for readability HOT 1
- Tracking test coverage and performance HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ppb-vector.