Add Vector3D crossproduct and Vector2D perpendicular function.
Describe geometric features of the two cross- and dot-product functions.
Description
Description
Details
Details
- Committed
elexis Nov 9 2017, 8:04 PM - Parents
- rP20427: Carthaginian range, workshop, elephant stable, mauryan stable, babylonian…
- Branches
- Unknown
- Tags
- Build Status
Buildable 3645 Build 6322: Post-Commit Build Jenkins
Event Timeline
Comment Actions
Some comments to a 2 years old friend as I was cleaning my stuffs ;-)
I don't understand the purpose of the comments.
We can just say that it returns the dot or the cross product, it's simpler ;-)
/ps/trunk/binaries/data/mods/public/globalscripts/vector.js | ||
---|---|---|
95 | I didn't, don't and won't care about that, but Returns for consistency. (I know you like those things :p) | |
106 | Among many other things | |
114 | The second "the" is false. | |
115 | I don't understand the comment |
Comment Actions
Some comments to a 2 years old friend as I was cleaning my stuffs ;-)
I'm getting(got) old. :S
Thanks for your feedback.
We can just say that it returns the dot or the cross product, it's simpler ;-)
Without the geometric interpretation, I wasn't able to understand some operations, for example this one (which is a yet to be committed follow up of the commit of this commit, i.e. rP20429).
While I had lots of linear algebra at school and university, I never saw a one-line computation of the distance of a point from a line in 2D space (used by the rivers map):
/** * Returns the distance of a point from a line. * @param {Vector2D} - lineStart, lineEnd, point * @param {boolean} absolute - If true, the function returns a non-negative number of the magnitude. * Otherwise the sign denotes the direction. */ function distanceOfPointFromLine(lineStart, lineEnd, point, absolute = true) { // Since the cross product is the area of the parallelogram with the vectors for sides and // one of the two vectors having length one, that area equals the distance between the points. let distance = Vector2D.sub(lineStart, lineEnd).normalize().cross(Vector2D.sub(point, lineEnd)); return absolute ? Math.abs(distance) : distance; }
(So I intended to retain these findings, including the intermediate ones.)
I'll look into clarifying the comments further on next occasion.
/ps/trunk/binaries/data/mods/public/globalscripts/vector.js | ||
---|---|---|
95 | Yeah well. (Speaking of consistency, also the two cross product parallelogram comments differ in phrasing). | |
115 | I squashed two sentences into one possibly awkward one:
| |
280 | (I did notice the article here but not above) |