• Content count

  • Joined

  • Last visited

Community Reputation

112 Neutral

About Sansros

  • Rank
  1. Going through some literature, I became confused about matrices in relation to extracting world space frustum planes.    The way being devised to extract frustum planes was to use the Projection matrix alone and to play around with column values and normalization. That I understood fine. I guess, the problem with this way was that all of the plane normals extracted were in camera space and in effect, all distances would be 0 since, even if the planes are far away in world space, they are always are the origin of the camera.    In any case, the solution to extract world space frustum planes was to still use the same method but to use the View * Projection matrix rather than just the Projection matrix alone. I fail to see though how the resulting matrix helps us get the frustum planes in world coordinates. If I multiply the View and Projection matrices, I get that my view frustum is now in the shape of a box and that vertices, multiplied by this, would be against the box planes. Thus, I am going from world space to NDC space.It would have made sense if I were told to take an NDC space plane normal and to multiply it by the inverse of the View matrix to get a world space coordinate but that's not the current issue.    Btw, for sake of context, here is the way the world space frustum plane was being extracted from the VP matrix:     Left Plane->Normal.X = - (m14 + m11) = 1.62566 Left Plane->Normal.Y = - (m24 + m21) = 0 Left Plane->Normal.Z = - (m34 + m31) = -0.211452
  2. Need clarification on partial derivatives

    [quote name='raigan' timestamp='1334668594' post='4932123'] Maybe I'm wrong, but can't you resolve your conundrum by considering that the surface you're describing is curved? IIRC partial derivatives are sort of like the linear approximation of the tangent at a particular point. "So is this saying that for every change of "something" in x, Z will increase by .7?" No, it's saying that at THAT specific point (x = 0.2, y = 0.3) the rate of change of z relative to the rate of change of x is 0.7. At a different point the rate of change may be difference, consider the derivative of y with respect to x dy/dx for a sine wave, at some points the derivative (slope of the function) is 0 (horizontal), and some points quite steep (closer to 1 or -1). This is the same "plugging different values of x gives me different partial derivatives" behaviour, because the surface isn't linear, it's curved. Only if the surface is linear/planar (flat) will the partial derivative be constant regardless of where you evaluate it. BUT: I'm quite rusty with my math so possible some or all of what I've said is wrong/mistaken. [/quote] Got it, that clarified it up when you mentioned curve vs planar surface.
  3. Need clarification on partial derivatives

    [quote name='alvaro' timestamp='1334628343' post='4931990'] You can think of that as saying that a small change in x results in a change in f(x) that is about 0.7 times the change in x. [/quote] Ok but isn't this relative to what your starting x value is? I mean, if I use 0.2 that is 0.2 units away from 0, not a small change relative to any arbitrary x value on the graph. In other words, if I use 0.2 as my delta but now have it relative to let's say, 1.5 instead of 0 on the x-axis, the output would now be: 2(1.7) + .3 = 3.7 [i]"You can think of that as saying that a small change in x (0.2 away from 1.5 on the x-axis) results in a change in f(x) that is about 3.7 times the change in x."[/i] The most general form I can think of it is like this: "Any change in x will result in [left][background=rgb(250, 251, 252)]2x +y for the Z output"[/background][/left]
  4. Need clarification on partial derivatives

    "[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]"if I were to vary x a little bit, what multiple of the change would the function change?". You can consider y to be fixed and x to be variable"[/background][/left][/size][/font][/color] [left]I think the above is mainly what I'm confused about. For example:[/left] [left]Z = x² + xy + y²[/left] [left]@z[/left] [left]---- = 2x +y[/left] [left]@x[/left] [left]Let's say now x = .2 and y = .3.[/left] [left]2(.2) + .3 = .7[/left] [left]I could have done this for any point of x and gotten different results for my output.[/left] [left]So is this saying that for every change of "something" in x, Z will increase by .7? [/left] [left]If I change X to 1.5 to get 2(1.6) + .3 = 1.1 so I'm confused in this sense. [/left]
  5. So I get the general idea of partial derivatives, meaning you make everything else constant and solve for one for the partial derivatives of a function. Let's say I have some surface whose Z is defined by function f which takes (x,y). If I find the partial derivative of f with respect to just x, I get a formula in which I can plug in some x and my constant y. The result is the slope of Z for that point on x. However, my x can be anything from 2 to 100 and my output will be slopes drastically different from one another. So I am failing to connect how a partial derivative means "it tells you how much Z changes for every change in X" to what I wrote above for any arbitrary X and its output. Oh and I came back to brushing up on partial derivatives due to the GPU gems article on water (in the normals and tangents part) [url=""][/url] so I am just trying to connect what I know above to what the article talks about.
  6. So the enemies of my game are mindlessly animation along pre-generated cutmull-rom splines, interpolating back and forth along the curve. I've set up a volume where these objects can roam and simply calculated a random position for the start of the curve and the end, setting the position of the enemies to the interpolated point along the curve. The problem is, is that obviously these will intersect and I want a way to avoid this. I could I guess have the bounding volume further split into regions where I would know where enemies are located. I could then somehow know at which point two enemies will intersect and temporarily fly away into an empty region and then resume my way onto the curve. Any suggestions?
  7. About rotation axis and orthogonality

    [quote name='Ripiz' timestamp='1324321003' post='4895413'] Matrix.CreateFromYawPitchRoll(y, x, z) isn't related to anything, it just creates rotation effect. It'll be in relation to an object's axis or global axis depending what you do with the matrix later. Matrix.CreateFromAxisAngle(angle, vector) simply creates matrix which rotates around any vector, not only standard like in YawPitchRoll case. Matrix.CreateFromYawPitchRoll(y, x, z) == Matrix.CreateFromAxisAngle(y, new Vector3(0, 1, 0)) * Matrix.CreateFromAxisAngle(x, new Vector3(1, 0, 0)) * Matrix.CreateFromAxisAngle(z, new Vector3(0, 0, 1)); I don't know much to comment on other questions. [/quote] For Matrix.CreateFromYawPitchRoll, I meant during the operation. If you pitch first let's say 90 degrees, than the local y-axis will now line up with the world z-axis. If you want to now yaw, will you yaw around the world's y-axis at (0,1,0) or the local's (0,0,1)?
  8. So I just want to talk about broad API calls and euler rotations and matrices for a second. Are euler rotations always going to be in relation to an object's axis? For example, in XNA there is: [code]Matrix.CreateFromYawPitchRoll(Rotation.Y, Rotation.X, Rotation.Z)[/code] [font="Lucida Sans Unicode"]1. So here I assume that you rotate on the object's Y-axis which coincides with the world's y-axis. After, you then would rotate on the x-axis (wherever that may be after the y rotation) of the object and not the world. Is this generally the case for euler rotations and these types of functions? I only ask to bring the distinction between functions like[/font] [code]Matrix.CreateFromAxisAngle(angle, vector)[/code] [font="Lucida Sans Unicode"] [font="Lucida Sans Unicode"]2. I only worry about orthogonality if I am creating a matrix from scratch right? In other words, the function above and quaternion functions in frameworks always drag axis along for the ride together. It's never like you can rotate one axis without effecting the others. Thus, maintaining orthogonality. [/font][/font] 3. For gimbal lock, I see online videos of the problem through a parent structure where if I am rotating (x,y,z), an x rotation will move the y and z axis. A y rotation will only affect the z axis and so on. However, I thought that each axis is moved along for the ride as mentioned above so they would always be orthogonal to one another. Can anyone clarify?
  9. Plane equation and distance

    [quote name='luca-deltodesco' timestamp='1324120480' post='4894744'] You can look at this in 2D to see why: dot(p,normal) = |p|.|normal|.cos(theta) and since the normal is of unit length, you get: dot(p,normal) = |p|.cos(theta) which from highschool trigonometry lessons of right angled triangles is the red distance shown on the diagram being the distance from the plane to the origin [img][/img] I like to think about the plane as being defined by it's normal and any point on the plane, with equation: (x - p) dot n = 0, for any point x then thinking about what the dot product says about two vectors when it is 0, the points 'x' that satisfy this are those such that if you take a vector from the point on the plane 'p' to the point 'x', it is perpendicular to the normal. If you use the diagram, and choose one of the points as being the 'p' and any other point on the line you'll see that to be true, and with some thought can visualise it in 3 dimensions also [/quote] Your explanation and diagram helped me extremely. I was just visualizing the vector from the origin to a point on the plane wrong which lead me to my confusion.
  10. Ok so I about understand all there is to planes except for the 'd' in the equation of ax+by+cz +d = 0 and finding the distance from world origin. While reading through here [url=""](GameDevJournal)[/url] at the third part is 'Get Plane Distance Using Plane Equation'. He says that d = -dotProduct(n,p) where n is a normal vector to the surface of the plane and p is already a point on the plane. This is a big 'well duh', you are figuring out 'd' here but won't the result always be 0? If you have a plan 100 units in whatever axis, the distance from the world-origin to this plane obviously isn't 0. Aside from that, if 'd' is the distance from the world origin to the plane, what point on the plane is this the distance from? I only ask because a plane can be oriented in different ways. Some points may be closer to the world-origin than others and so on.
  11. Matrix rotation and axis change (XNA)

    [quote name='Trienco' timestamp='1306035992' post='4814101'] [quote name='Sansros' timestamp='1306035786' post='4814099'] [code]world = identity * rr * tr;[/code] [/quote] Because the order in which you multiply you FIRST translate and then rotate. Read matrix multiplications from right to left. Also multiplying with identity is pointless by definition and just like multiplying a number with 1. [/quote] So what I wrote is fine if I read right to left and do: world = tr * rr; correct?
  12. If I rotate a sprite 90 degrees along the Z-axis and then multiply that matrix by a translation matrix, I expect my sprite to move upwards. This is because the x-axis of the sprite is now aligned with the world's z-axis. However, the sprite instead still moves right or left along the world's z-axis. Can anyone explain what's wrong? [code] //expect this to change the axis on which the sprite works on Matrix rr = Matrix.CreateRotationZ(MathHelper.ToRadians(90.0f)); //moves to the right instead of upwards like I expect Matrix tr = Matrix.CreateTranslation(new Vector3(2, 0, 0)); world = identity * rr * tr;[/code]