Transform Xojo Point From Cartesian's Built-In System

How do I do this? I just want normal coordinates, if that’s a good way of describing it.

Xojo seems to have Cartesian as a built-in system. How do I transform this to a more regular type of coordinates?

I don’t know the proper names so thats why I might lack jargon vocab.

Thanks

http://en.wikipedia.org/wiki/Cartesian_coordinate_system

Not sure what you mean by “normal”, Oliver. Cartesian coordinate systems are about as “normal” as you can get for a 2-dimensional, x-y plotting system (think screen). Other coordinate systems (i.e., Polar, Cylindrical, Spherical, etc.) are for specific purposes with data that is best represented by them. The only PITA for me is that XOJO’s coordinate system has the “0” origin at top left rather than bottom left like a typical x-y plot would be (which makes it a "modified Cartesian coordinate system). Specifically, what is it that you are trying to accomplish that standard Cartesian coordinates doesn’t give you?

Sounds like you understood me. Thanks for trying to understand me with my lack of knowledge.

Are there any methods which I can use? Thanks

What are you trying to plot (or position) that doesn’t fit the standard “x,y” grid scenario?

Oliver, do you mean the canvas shows the coordinates, somehow, upside down? if this is your issue, you just have to inverse the whole thing, by subtracting the value you wish to plot from the canvas1.height property.
I mean, if you’d like to draw, on canvas1, a temperature chart showing a 20 degrees plot at a lower position than a 40 degrees mark, you just have to:

canvas1.Graphics.Pixel(10, canvas1.height-20) = RGB(0, 0, 0) canvas1.Graphics.Pixel(30, canvas1.height-40) = RGB(0, 0, 0)

instead of:

canvas1.Graphics.Pixel(10, 20) = RGB(0, 0, 0) canvas1.Graphics.Pixel(30, 40) = RGB(0, 0, 0)

hope this helps,
a

And if you want to plot negative coordinates, you can translate them, by width/2 and height/2, for example.

My ‘Intersection’ method seems to still always return true. Thanks for all the help btw.

So is your question about Cartesian coordinates or why your intersection code doesn’t work?
if the latter, it might help to post to code… if the former then you are mixing topics

[quote=158856:@Dave S]So is your question about Cartesian coordinates or why your intersection code doesn’t work?
if the latter, it might help to post to code… if the former then you are mixing topics[/quote]
I have been told my bug could have something to do with the Y intersection but I have not managed to get that to work. Here is my modifications after transforming the coordinates.

Your “Intersects” routine has “return true” as the last line, so it will definitely always show true.

Look at this site for more help. I have it running as Xojo code if you need more help but you should try it first:
http://www.vb-helper.com/howto_segments_intersect.html

Note that this site takes care of parallel lines and vertical lines, which yours doesn’t appear to…

[quote=158917:@Bill Gookin]Look at this site for more help. I have it running as Xojo code if you need more help but you should try it first:
http://www.vb-helper.com/howto_segments_intersect.html

Note that this site takes care of parallel lines and vertical lines, which yours doesn’t appear to…[/quote]
I have believe I have already tried this. I am not so sure if it is that part of the code which I got wrong.

As for the ‘return true’ at the end. That does not mean that it will always return true actually. This is because if the tests prior return false then that will not be the case. The code seems to be very similar to the method i am currently using anyway.

Thanks a ton

I only see a non-true return if they’re parallel lines, not for any other case. Am I missing something?

Here’s a quick demo using Gookins reference for intersects. Drag the endpoints and the lines turn red when intersecting. http://home.comcast.net/~trochoid/dragSect.zip

A possible keyword, what your trying to deal with in the coordinate transform I know of as Y-Up vs Y-Down orientation.

In your code Drawline has it’s coordinates mixed, it’s (x1, y1, x2, y2)

Sub Drawline(g as graphics, LINE AS LINESHAPE) //G.DRAWLINE LINE.x1, LINE.x2, LINE.PlotY1, LINE.PlotY2 G.DRAWLINE LINE.x1, LINE.PlotY1, LINE.x2, LINE.PlotY2 End Sub

If you want to use t’other co-ordinate system ( bottom up ) as opposed to top down, simply invert the axis using what you know.

y = context.height - y

I have to do this all the time when going between Xojo and OS X APIs. For a rect, you need the rect’s bottom (no sniggering).

rect.y = context.height - rect.bottom

[quote=158962:@Will Shank]Here’s a quick demo using Gookins reference for intersects. Drag the endpoints and the lines turn red when intersecting. http://home.comcast.net/~trochoid/dragSect.zip

A possible keyword, what your trying to deal with in the coordinate transform I know of as Y-Up vs Y-Down orientation.

In your code Drawline has it’s coordinates mixed, it’s (x1, y1, x2, y2)

Sub Drawline(g as graphics, LINE AS LINESHAPE) //G.DRAWLINE LINE.x1, LINE.x2, LINE.PlotY1, LINE.PlotY2 G.DRAWLINE LINE.x1, LINE.PlotY1, LINE.x2, LINE.PlotY2 End Sub[/quote]
Thanks for pointing this out.

[quote=158971:@Sam Rowlands]If you want to use t’other co-ordinate system ( bottom up ) as opposed to top down, simply invert the axis using what you know.

y = context.height - y

I have to do this all the time when going between Xojo and OS X APIs. For a rect, you need the rect’s bottom (no sniggering).

rect.y = context.height - rect.bottom

Okay, thanks.

I got this part to work as intended, I believe.

I believe you are right. I have tried many cases including non-parallel and parallel lines and it still does not seem to return false. I will have a read through the posts on here and see if I can do anything about that.

Thanks