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

Author Topic: Question about the coordinate system (how to plot negative x and y)  (Read 2154 times)

0 Members and 1 Guest are viewing this topic.

pamelablue

  • Newbie
  • *
  • Posts: 3
    • View Profile
Hello guys and girls!

I am new to programming and I have a faculty assignment that involves using SFML.

To be precise, it involves drawing a shape defined by 2 math functions and then performing certain operations (translation, rotation...etc).

Part of the shape is defined by points which have negative x and y coordinates.

From what I understood, SFML coordinate system has its origin (0,0) in the top left corner of the screen while max coordinates are defined by the window size.

I am puzzled on how I can plot these points with negative coordinates in SFML. I have read an article about SF view coordinates which have an inverted x axis so I thought about faking the whole construction by creating a coordinate system within a coordinate system...but I am not sure whether this will help in the long run.

One of the tasks in the project is to do a mirroring projection over the x axis and since the x axis is basically the top border of the screen, I am not sure how to transfer a point - for example a point with coordinates (x=5,y=1) would become (x=5,y=-1) in normal circumstances.

Am I overlooking something being inexperienced as I am?

I am really looking forward to digging deeper into this and I love SFML as it is my first tool that allowed me to play with animations.

Below, I have attached the shape. as you can see, part of the shape is in the negative values of x & y so I am not sure how to do it. If i create another coordinate system (not sure how this "work around" will perform), i am limited as a non-expected input from the user (when it comes to entering a translation vector) could mess the whole construction.

Many thanks!

Addendum: I have constructed the object by pretending the middle of the screen is the middle of the coordinate system( window size 1000,1000 puts the middle at 500,500). Works fine so far, will have to go through every possibility in the assignment to see if this will the the long term solution.
Of course, I would still love to hear any ideas or advice!
« Last Edit: January 08, 2021, 06:01:47 pm by pamelablue »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Question about the coordinate system (how to plot negative x and y)
« Reply #1 on: January 08, 2021, 06:12:50 pm »
Quote
From what I understood, SFML coordinate system has its origin (0,0) in the top left corner of the screen while max coordinates are defined by the window size.
That's just the default. Using sf::View (see doc, tutorials, etc.) you can show any part of your scene into the window, including parts where coordinates are negative.
Laurent Gomila - SFML developer

 

anything