Premandrake

Members
  • Content count

    330
  • Joined

  • Last visited

Community Reputation

175 Neutral

About Premandrake

  • Rank
    Member
  1. Well, if this were WPF, you could just have a ResourceDictionary and include it in the MergedDictionaries, but alas :). In Silverlight, it's a bit trickier. Your best option to have shared styles across DLL's is to have a common DLL that has your App.xaml in it. Silverlight supports resolving App.xaml resources with {StaticResource}.
  2. [.net] Build problem vs2008

    Try this thread.
  3. Convert Lat Lon to Polar

    It sounds like you are trying to find the great circle distance between the two points. Simplest solution is to use the formula given in the link above (remembering to convert your latitude/longitude to radians), and that will give you the distance. The "bearing" doesn't really have a meaning in spherical co-ordinates. Perhaps you are trying to interpolate between the two points? If so, you should use quaternions, as spherical linear interpolation follows the great-circle arc at a constant speed. See here for a good background.
  4. Angle between two 3D points

    Quote:Original post by tKircher All i'm doing is taking the dot product of the two points (taking the x, y, z of each point as vectors and dotting those), then using sin, cos, and tan on the dot to get the three values i'm after. I figured an implicit magnitude of 1 would simplify the equation (divide by 1 is sorta redundant) Well, there are a few problems here :). First, the formula does not generalize to plug in sin/cos/tan/asin/atan, it only works with acos. Second, unless you are using normalized vectors, dividing by the magnitude is actually very important. The most serious problem, is I misread your question (went off the title of the post, not the content ;)). The formula I gave you will certainly compute the angle between two vectors. However, that's all it will do. jyk's post has some good ideas on how to accomplish this.
  5. Math thingie

    You are correct, a little trig. will do wonders here :). You are basically applying a rotation about the first edge to the mesh (since the rotation is in this plane, you can just use any point on the edge). See here for a good background of doing this. Or, if you already have a decent matrix/quaternion library, it should support building this matrix for you. First, you calculate the basis vectors for your rotation space. Your x basis is your "fixed" edge. The z basis is the vector between an endpoint on the first edge, and the adjacent vertex. The y basis is the perpendicular vector to these two (caclulate using the cross product). Basis vector explanation. Then transform an x rotation (with the angle of the slope) by your basis matrix, and convert it to rotate around the point. The apply that matrix to all the points to get the "top" face of the object.
  6. Angle between two 3D points

    a dot b = |a||b|cos(theta), where theta is the angle between the two vectors. So, to compute theta we need (forgive the bad ascii art): ( a dot b ) theta = acos(---------) ( |a||b| ) a dot b is just the 3d dot product, nice and efficient :). |a| is the magnitude of the vector a.
  7. TopCoder.com : coding contest scene?

    Woohoo! Another thread about topcoder :). I compete as gladius over there. I recommend trying a few of the practice problems out if you haven't tried something like it before.
  8. Random Numbers in C#

    float RandomToScaled(double r, double maximum) { return (r - 0.5) * 2 * maximum; } Random random = new Random(); // This will return a number between -5000 and 5000. RandomToScaled(random.NextDouble(), 5000);
  9. Path Smoothing

    Catmull-Rom splines only need the two points surrounding the points you are interpolating between. Check out this page http://www.cubic.org/docs/hermite.htm for a nice overview of using splines for interpolation.
  10. Or this one: int countBits(int num) { return num ? countBits(num & (num - 1)) + 1 : 0; } Which if optimized for character count is pretty darn short: int c(int x){return x?c(x&x-1)+1:0;} So, here is a new challenge, can anyone come up with a method that uses less characters?
  11. Finding Prime Numbers

    While we're at it, I figured I'd throw in my two cents :). Here is a sieve implementation I wrote a while back that is pretty fast, it calculates all the primes up to 10 million in less than a second on my machine. This code is not big endian safe. #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> const int MAXNUM=10000000; unsigned int sieve[MAXNUM/64 + 2]; void calcSieve() { for (int i=0; i<sizeof(sieve)>>2; i+=3) { sieve[i] = 0x6DB6DB6D; sieve[i+1] = 0xDB6DB6DB; sieve[i+2] = 0xB6DB6DB6; } sieve[0] |= 6; for (int i=2; 4*(i*i+i)+1<=MAXNUM; i++) { if (sieve[i>>5]&(1<<(i&31))) { int factor = (i<<1)+1; for (int j=factor+i; j<(MAXNUM/2)+1; j+=factor) { sieve[j>>5] &= ~(1<<(j&31)); } } } } bool isPrime(int num) { if (!(num&1) && num!=2) return false; num >>= 1; if (sieve[num>>5]&(1<<(num&31))) return true; return false; } bool isPrimeSlow(int num) { for (int i = 2; i*i <= num; i++) if (num % i == 0) return false; return true; } int main() { calcSieve(); //printf("Incorrect results:\n"); //for (int i = 1; i <= MAXNUM; i++) // if (isPrime(i) != isPrimeSlow(i)) printf("%d, ", i); //printf("\n"); printf("Primes less than 100:\n"); for (int i = 1; i <= 100; i++) if (isPrime(i)) printf("%d, ",i); printf("\n"); }
  12. int countBits(int num) { return num ? countBits(num>>1) + (num&1) : 0; } Does that count? ;)
  13. how to get doc or view object ?

    You want to use your MainFrame class (CMDIFrameWnd or CSDIFrameWnd) to issue the ShowWindow() call. You can do something like the following: #include "mainfrm.h" CMainFrame *mainFrm = (CMainFrame*)AfxGetMainWnd(); pMainFrame->ShowWindow(SW_HIDE);
  14. Fonts, Localization , and the 360

    I'd imagine the developer support at Microsoft might be able to better handle this type of question :).
  15. It does look like there is a bug in the Buffer code (but I'm not sure of the intent). In the ctor(Device, Buffer) it does the following: // Oops, accessing .Value without having checked .HasValue first ref void modopt(IsExplicitlyDereferenced) pinned local1 = &description.WaveFormat.Value; if (description.WaveFormat.HasValue) { *((int*) (_dsbufferdescPtr1 + 0x10)) = local1; } int num1 = **(((int*) device.pComPtr))[12](device.pComPtr, _dsbufferdescPtr1, local2, 0); if (description.WaveFormat.HasValue) { memcpy(local1, *((void modopt(IsConst)**) (_dsbufferdescPtr1 + 0x10)), 0x12); } A related note, Reflector has saved my bacon many times in the past. That's how I got the information above.