Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 03 Jul 2006
Offline Last Active Sep 19 2014 08:49 AM

#5181038 OIT (Order Independent Transparency)

Posted by apatriarca on 17 September 2014 - 10:10 AM

The Intel solution is based on a quite recent and, as far as I know, Intel-only extension. The Weighted Blended OIT is more general, but it is an approximation. There are also other methods (A-buffers for example). I don't think this is a solved problem and in many cases sorting is still probably the way to go. The best method depends on what you are trying to do and the scene you are trying to display.

#5180962 Formulas, Math, and theories for RPG combat/leveling systems?

Posted by apatriarca on 17 September 2014 - 04:09 AM

IMHO If you want low level players/monsters to have a chance against higher level ones, then you should rely less on stats and add more depth and strategy to your combat system. This is in fact the only way a weaker individual can beat a stronger one in real life too. If you have to fight with a boxer, you try to stay at the distance. If you are fighting with someone with a gun, you hide and try to disarm or use surprise or.. 

#5162268 Editing Bezier Splines while maintaining C1 Continuity

Posted by apatriarca on 23 June 2014 - 01:46 AM

To maintain C1 continuity between consecutive (cubic) Bézier splines you have to maintain the following equations:


P3(i-1) - P2(-1) = P1(i) - P0(i)

P3(i-1) = P0(i)


where the index in the parenthesis represents the index of the curve in the spline. The derivative/tangent at the beginning (end) of Bézier curve is in fact parallel to the edge between the first two (last two) control points. If the two curves have different degree you have to multiply each part of the equation with the degree of the corresponding curve.

#5148706 Can you quickly visualize how a quaternion would look on top of your head?

Posted by apatriarca on 22 April 2014 - 06:48 AM

If you take a general quaternion like 0.6 + 0.3*i + 0.2*j -  0.71*k you may first look at the real part and observe this should be equal to cos(alpha/2) for some angle alpha. 0.6 is greater than 0.5 which is the cosine of 60 degrees, but less then sqrt(2)/2 ~= 0.71 which is the cosine of 45 degrees. It should then be something in between, let's say 52.5 which is in the middle (the correct angle is 53.13 degrees) and thus we have a rotation of approximately 105 degrees around the axis defined by its imaginary part. This is basically how you can get a rough idea of what a quaternion does.

#5145766 Quaternions rotation code

Posted by apatriarca on 09 April 2014 - 02:49 PM

I do not know the Unity API, but I think it is the rotation around the axis cross((0, 1, 0), mFrontWheelNormal) with angle equal to the angle between the two vectors. The effect of the rotation should be to move something aligned with (0,1,0) to something aligned with mFrontWheelNormal.

#5145703 Quaternions rotation code

Posted by apatriarca on 09 April 2014 - 09:55 AM

When you multiply two quaternions you are composing the two transformations together. The resulting rotation is the rotation obtained by first rotating according to right-most quaternion and then according to the left-most one. In your case, your first rotation maps (0, 1, 0) to mFrontWheelNormal and you then rotate around the normal vector by the angle Source.rotation.eulerAngles.y.

#5145085 Rotate a quaternion

Posted by apatriarca on 07 April 2014 - 10:44 AM

If you want to combine rotations, you have to multiply together the two quaternions. If q_1 is the first rotation and q_2 is the second rotation, then q_2*q_1 is the rotation obtained by first rotating using q_1 and then q_2. q_1*q_2 is the rotation obtained by first rotating using q_2 and then q_1. Indeed, q_2*q_1*v*(q_2*q_1)^{-1} = q_2*(q_1*v*q_1^{-1})*q_2^{-1}.

#5142607 draw 2d line with clipping

Posted by apatriarca on 27 March 2014 - 09:56 AM

There is no need to execute the loop to obtain the correct values of x, y and error. The error is simply the vertical distance from the line to the current pixel. If (x_0, y_0) the better approximation of the first pixel to draw on the screen and y = m*x + q is the line equation, then error = m*x_0 + q - y_0. You should then be able to draw the following pixels without problems.

#5142534 Help with Plasticity formula.

Posted by apatriarca on 27 March 2014 - 05:30 AM

That arrow is usually used when describing algorithms and represents an assignment, an update of the variable the arrow points to. ||Sp - I||2 is the spectral norm of the matrix Sp - I. The spectral norm of a matrix A is the square root of the maximum eigenvalue of AHA where AH is the conjugate transpose of A (the transpose if the matrix is real).

#5140930 Quaternions: convert between Left-Right handed without using Euler

Posted by apatriarca on 21 March 2014 - 06:09 AM

Let M be the (3x3) transformation matrix between the Blender coordinate system and the Unity one. Then the axis is simply transformed using M and the angle should change sign (since M does not preserve the orientation). You thus have to negate the imaginary part and then apply M to it.



The transformation between Blender and Unity coordinate systems is, if I remember correctly, (x, y, z) -> (y, z, -x). If I thus have a quaternion q0 + q1*i + q2*j + q3*k, the corresponding quaternion should be q0 - q2*i - q3*j +q1*k.

#5140688 Inverse Proportion and Zero

Posted by apatriarca on 20 March 2014 - 09:57 AM

I'm not sure I understood your post. Anyway, what about (10 - x)*25.5 ? It is equal to 255 when x is zero and equal to 0 when x is 10.

#5134720 This is what atan2() does if given two Vector2D points on 2D plane?

Posted by apatriarca on 26 February 2014 - 05:07 AM

There is no need to convert these vectors to angles to compute a rotation matrix. All you need to compute a rotation matrix in 2D are the cosine and sine of the angle and you already have them encoded in the direction of the difference vector. You indeed simply have to normalize the difference vector:


(cos(angle), sin(angle) ) = normalize(P2 - P1).


If you think you have to compute the angle to compare them between different fingers positions, then it is not true again. If P3 and P4 are different positions of your fingers, then you can compute the cosine and sine of the rotation angle between the two vectors by simply using a complex division. If do not know complex numbers I suggest to learn about them, but you can implement the division using the following formula:


(a, b) / (c, d) = ( a*c + b*d, b*c - a*d ) / (c*c + d*d).

#5125823 .obj file loader

Posted by apatriarca on 23 January 2014 - 03:30 AM

Is there any reason you are using (*model).GetIndices() instead of model->GetIndices() ? 

#5125637 Barycentric coordinates of circumcenter of tetrahedron

Posted by apatriarca on 22 January 2014 - 08:10 AM

The steps in the derivation are very similar to the steps in the triangle case and you should get:


Dot(B-A,B-A)*s + Dot(B-A,C-A)*t + Dot(B-A,D-A)*u = (1/2)*Dot(B-A,B-A)
Dot(C-A,B-A)*s + Dot(C-A,C-A)*t + Dot(C-A,D-A)*u = (1/2)*Dot(C-A,C-A)

Dot(D-A,B-A)*s + Dot(D-A,C-A)*t + Dot(D-A,D-A)*u = (1/2)*Dot(D-A,D-A)


which you can then solve using Cramer's rule (or something else). 

#5125616 Mathematics for 3D programming - Exercises

Posted by apatriarca on 22 January 2014 - 05:01 AM

Making a simple 3D game/tech demo or a ray tracer or .. is IMHO probably one of the best way to exercise those math skills.