raycast(?) error

Hi, Ive got a MASSIVE PROBLEM when raycasting.

I have a ray, from a point (-75,0) in my world. Now, I have the ray at an angle of 90 degrees, however, it is NOT pointing at 90 degrees.

here is my code

for the Actual Raycast (I have my own function for raycasts, so that I can easily call them)

Code:
void SimpleRayCast(b2World* WORLD, b2Vec2 START, float DAngle,float Length)
{
      float32 segmentLength = Length;
      DAngle = -DAngle*degrees;
      b2Vec2 ENDPOINT(START.x,START.y+Length);
      b2Vec2 C1( -sin(DAngle),cos(DAngle));
      b2Vec2 C2(cos(DAngle),sin(DAngle));
      b2Mat22 ROTMATRIX(C2,C1);
      ENDPOINT = b2Mul(ROTMATRIX,ENDPOINT);
      b2Segment segment;
      segment.p1 = START;
      b2Vec2 END = ENDPOINT;
      segment.p2 = END;
         float32 lambda=1;
         b2Vec2 normal;
         b2Fixture* fixture = WORLD->RaycastOne(segment,&lambda,&normal,false,NULL);
         b2Color laserColor(255,0,0);
         if(fixture)
         {
            b2Vec2 p1 = segment.p1;
            b2Vec2 p2 = (1-lambda)*segment.p1+lambda*segment.p2;
            glBegin(GL_LINES);
   glVertex2f(p1.x, p1.y);
   glVertex2f(p2.x, p2.y);
   glEnd();
         b2Body* BODY = fixture->GetBody();
         if(BODY->GetMass()!=0.0)
         {
            b2Vec2 FORCE((p1.x-p2.x)/-1,(p1.y-p2.y)/-1);         
            BODY->ApplyForce(FORCE, p2);
         }         
         }
         else
         {
            b2Vec2 p1 = segment.p1;
            b2Vec2 p2 = segment.p2;

            glBegin(GL_LINES);
            glVertex2f(p1.x, p1.y);
            glVertex2f(p2.x, p2.y);
            glEnd();
         }
}


and for calling one. (the variable raycastAngle has already been defined as 90)
Code:
b2Vec2 START(-75,0);
   SimpleRayCast(WORLD,START,raycastAngle,300);



see attached screenshot for the problem
Your problem might be because you're rotating a point around the origin, but expecting to rotate around another point. Build your ENDPOINT based on the length only, rotate it and then add the START point.

The way you do it, you rotate the vector (-70, 300) around the origin 90 degrees, which gives you (-300, -70) and that gives you what you see in the screenshot.

Instead, rotate the vector (0, 300) 90 degrees to (-300, 0) and add (-70, 0) to get (-370, 0) which is a 300 unit long vector going left.
aw, crap Im such an idiot, I should have noticed that. oh well, thanks, but to be honest I had given up and was using the code from the testbed, where it uses a body or somthing

Original thread: https://box2d.org/forum/viewtopic.php?t=3313