Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - aaranaf

Pages: [1]
1
General / Math: Finding a point that is perpendicular to another point.
« on: August 03, 2013, 01:23:52 am »
So here's what I want to do. I want to find the point in 2d-space for C.
I have the point A and B and the distance from B to C.
I know C is perpendicular to B. If someone could point me in the right direction on this it would be greatly appreciated.

2
General / Re: Tracking a point on a sprite after rotation.
« on: July 18, 2013, 05:34:11 am »
Got it to work!
Thanks zsbzsb.

3
General / Re: Tracking a point on a sprite after rotation.
« on: July 18, 2013, 02:34:27 am »
Maybe I should clarify: I have a Point X witch represent the anchor when the rotation is currently at 0 what I want to do is after the rotation have been done I want that anchor to be placed on the same part of the image so newly created bullet actually comes out from the right part of the sprite instead of staying at the last spot witch no longer is the "tip of the gun" so to speak.

    sf::Vector2f curPos = GetSprite().getPosition();
    sf::Vector2i position = sf::Mouse::getPosition(window) ;
    sf::vector2f Anchor = GetSprite().getPosistion();

    const float PI = 3.14159265;

    float dX = curPos.x - position.x;
    float dY = curPos.y - position.y;

    rotation = (atan2(dY, dX)) * 180 / PI;

    GetSprite().setRotation(rotation - 90);
    Anchor.x = //Here is where i need the new location
    Anchor.y = //Here is where i need the new location

 

I put a simple ms paint picture as an attachment, maybe it can explain on what I mean.

4
General / Tracking a point on a sprite after rotation.
« on: July 18, 2013, 02:03:26 am »
Hi I'm a bit stuck on how I can track a point on a sprite after rotation is applied.

Let's say I have a point that I've saved away that I want my bullets to spawn at, typically the end of a rifle for an example. But after I execute the rotation code:
        sf::Vector2f curPos = GetSprite().getPosition();
        sf::Vector2i position = sf::Mouse::getPosition(window) ;

        const float PI = 3.14159265;

        float dX = curPos.x - position.x;
        float dY = curPos.y - position.y;

        rotation = (atan2(dY, dX)) * 180 / PI;

        GetSprite().setRotation(rotation - 90);
 
I want that point X to stay with the sprite so I can use it as an anchor for my bullets. I know there's and formula for it somewhere but I have not yet found it. Can anyone point me in the right direction?

Pages: [1]