-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vector3 direction and Plane distance #24713
Comments
That's really up to you. A vector has a direction and a length (aka magnitude) but it does not have a position in space. If you place the vector in origin then it happens so that its components are identical to the coordinates of the vector's end point.
As already stated, vectors do not have a fixed position in space. In particular, normal vectors solely indicate direction. They also usually have unit length. For planes the normal indicates the direction of the plane and the distance indicates the distance between the plane and the origin of the coordinate system.
The documentation of types such as |
Thanks @mikedn.
Yes, but it should refer to the math standerds used with this type. I'm an engineer but I couldn't understand how these work even after looking at source code and reading some topics in Wikipedia. |
Like many types, it also isn't necessarily designed for "general" use. There are a multitude of APIs that require some prior knowledge or experience to use them. Much of the
I don't think there is any "standard" for these. Its mathematical rules/concepts and the best open resource might be Wikipedia or some random blog post.
https://en.wikipedia.org/wiki/Euclidean_vector If you have a vector (1, 2, 3), then the direction is +1 along the X axis, +2 along the Y axis, and +3 along the Z axis. This is from whatever the "origin" point is (which may be implicit, but is data external to the vector itself) |
Hmm, if you want to treat a vector (x, y, z) as a point then think of it as an arrow that starts from origin and ends in the point (x, y, z). That arrow has a length and a direction (basically the angle between the arrow and the X axis). Now move this arrow from origin but do not alter its length or direction. What you get is the same (x, y, z) vector. It may be more useful if you try to map the abstract concept of vector to something from the real world - velocity for example. The velocity of a moving object is a vector and like all vectors has a length and a direction. The length tells you the speed of the object. The direction tells you where the objects goes (left, right etc.). The velocity does not tell you where the object is, its position.
It's all math really. It has nothing to do with programming. |
@tannergooding
This is why I asked what the implementation means. |
@mikedn |
What makes you think that?
Huh? Apparently you're still confusing math with programming. |
Length has nothing to do with the position. || End - Start || so it's relative. Or look at the component form, and you'll see that the origin doesn't matter. |
@gfoidl |
You've already been told that a vector doesn't have an associated position in space. It's sometimes useful to think that a vector starts in origin (or wherever else makes sense in a given context) but the fact is that the position information isn't encoded in a vector, only its direction and length are. |
@mikedn |
Exactly. Another way of looking at it is that the x, y and z components of a vector represent the length of vector's projection on the X, Y and Z axes of the coordinate system. And given the length of these projections the vector's length is The angle(s) that give you the direction can also be computed using basic trigonometry concepts even though when you're using vectors you're more likely to resort to using the dot product rather than actual trigonometry formulas. Nowhere in these calculations do any point coordinates appear, it's all about lengths and proportions. |
@mikedn |
As stated in the issue you linked, the implementation isn't following any convention but the standard mathematical rules for these types (generally using the rules for Euclidean Space). |
@mikedn
This indicates that the origin is not always the start point of the vector, which is strang and confusing! What is the rule used here if this is not a bug? |
See the response I gave here: https://github.com/dotnet/corefx/issues/26497#issuecomment-359320608. The .NET implementation is not doing anything drastically different from any other major vector math library in production use today. |
The only thing that it is showing is that you have no clue what you are talking about (which is not a bad thing by itself, nobody's born knowing everything) but at the same time you're arrogant enough to claim that these types are somehow broken and suggest "improvements". In reality, the only thing that is broken here is your attempt at using math tools without knowing math and then blame it on "implementers" for not explaining clearly how their implementation deviates from your imagination. |
@mikedn |
That's part of the problem. You keep insisting in studying these "types" (and btw, the SIMD aspect is completely irrelevant) when in fact you should be studying the math behind these "types". Without the math these types aren't very useful.
If you learn the math you'll find that these types are pretty simple and clear. And in those rare circumstances where the docs omit mentioning implementation choices (e.g. I don't think that the docs mention anywhere the choice of coordinate systems hand-ness) you'll find that it's pretty easy to figure it out by yourself. Of course, that's not an excuse for such information to not be included in the docs. It's just that it's a rather minor problem. As for adding more capabilities, well, let's see:
In many cases normal vectors are normalized, that is, they have length = 1. Some computations simply require normalized vectors for correctness purposes. In other cases normalized vectors are not required but they're used to avoid issues with floating point precision. And normalized or not, normal vectors can't have length = 0, they'd lose the direction information. So it's kind of bizarre to have a
As repeatedly stated previously vectors do not have a position in space so it's not clear what you mean by end point. Vectors can be used to represent many things (normals, velocities etc.) and they can also be used to represent positions in space (aka positions vectors). Then you have 2 vectors (v1 and v2) that represent 2 points in space then the vector that gives you the distance and direction between those points is
I'm getting the impression that you think that these types might be useful to you not due to the math concepts they're supposed to represent but due to the SIMD stuff. That's really the wrong way to look at SIMD, if you need SIMD then use |
This exactly my problem, becuase of how you announced these types in what's new :) |
Hmm, the Matrix types are not using SIMD (except perhaps for some methods that happen to use Vector2/3/4 but that's pretty much irrelevant). Same for I'm not sure what lead you to believe that these types are using SIMD. If there's something in the docs that makes you think that then it would be useful to point to the relevant doc pages, they definitely need to be improved/fixed.
They can be used by anyone who needs vector operations for whatever purpose. But they're really targeted at 3D graphics and collision detection, as used in games. They're probably less useful for, say, scientific applications, in part due to the fact that these types use For general purpose SIMD the only thing that matters is
You probably didn't add the |
https://docs.microsoft.com/en-us/dotnet/framework/whats-new/
also in System.Numerics Namespace : https://docs.microsoft.com/en-us/dotnet/api/system.numerics?view=netframework-4.7.1
|
@mikedn By the way, I was not wrong when I talked about vectors pos.
I quoted another lines talking about vectors types from wikipedia , among them bound vectors, in earlier posts, but you ignored it, insisting that there is only one type of vectors. |
Yeah, that stuff is IMO misleading. I think you should open an issue in the docs repository to have this at least discussed a bit if not fixed. As already mentioned, matrices and some other
You're not wrong but you're not right either. The notion of bound vector exists but it is a bit of conceptual gimmick. In does not exist in vector space where the notion of vector really comes from. Nor you'll easily find a library (at least in the 3D graphics domain) that has such a type built in. It's neither efficient nor flexible to store in a type information that's not widely used/necessary. Best example is the position vector. It's starting point is the origin of the coordinate system. But that's "by definition" so to speak. There's no need for a type with 6 components in it with the first 3 of them being always 0.
The |
@mikedn
I opend an issue week ago about the incomplete out of date helpviewer offline topics, but no response.
Do you mean you will build other types? Hope so. |
Offline help viewer? Does that still exist? You'd probably get better feedback if you ask for specific things. For example, they could easily add a note to the More generally, there certainly is room for improvement in the documentation area. But I doubt that anyone will spend a lot of time adding detailed explanations about what a vector3 is and how it is supposed to be used when such information is widely available on the Internet and very much a prerequisite for using such types.
Me? No, I do not work for MS. MS? I can't comment on their plans but I doubt they will do that. They're not in the business of making math libraries. At best they'll add some more basic stuff if people ask for it and it's not too much trouble to implement it.
Yes, and many have done that already. It's likely that the main reason MS added these types is the SIMD support, that's not something that "any programmer" could have done as it requires JIT compiler & runtime support.
Yes but that doesn't mean that MS has to provide everything one may need. As already stated, they're not in the business of making a math framework. They're making a general purpose framework that also offers some math primitives. Others may use those primitives to build more advanced libraries. |
I think the questions have been answered, and this issue can be closed. Please re-open if I am incorrect. https://github.com/dotnet/corefx/issues/23448 is a general "System.Numerics.Vectors docs need to be updated" issue that we will move to https://github.com/dotnet/docs. |
SIMD-Enabled types are poorly documented, so I need to ask about two things:
Vectors are defined by only one point . Does this mean that its direction is from the origin point to that point?
The Plane structure is defined by a Vector3 normal to it and a distance. If normal vector starts from the origin to a point on the plane surface, why do we need a distance? What does it mean? Or if the point of the vector is not on the plane surface, what does it mean?
Maybe I miss something, but as I said, documents doesn't help. So, what do you really mean with this implementation?
I suggest adding a constructor to the Plane Structure, that has one parameter "normal" of type Vector3. It can get the distance frome:
d = normal.Length.
This is usefull when we know the intersection point of the normal vector with the plane.
And please, make the documantaion more detailed.
Thanks.
The text was updated successfully, but these errors were encountered: