How can we convert the heading, of a Netlogo turtle, into a line equation (y = mx + c ) so that it can be compared to another line equation (eg that of patches representing a wall) ? (turlte heading vs wall made of patches - both treated as lines that will intercept at one point)
I need to convert the heading of a turtle into a line equation. Then compare the heading line equation with the line equation of a wall (which will have either a fixed x or a fixed y – depending on whether the wall is vertical or horizontal)
There is an interception of lines example code in the library (that I don’t understand that well) which is using moving segments. I think what I am after is a bit simpler.
Perhaps a better starting point would be the code below that I found in one of the forums.
to-report calculate-line [ x y angle]
let m tan angle
let A m
let B -1
let C ( - m * x + y )
report (list A B C)
end
What must be done in order to 'read' the x and y values of the current turtle's heading and input those into the equations? Similarly, how can a set of patches that have been colored to represent a wall, can be converted into a line equation that will be used to check possible intersection (between the heading line equation and wall line equation)?
For example, I have create a line/segment of grey patches using the below code to represent the wall and given it is straight, there must be a way to convert this into a line equation (which will have a fixed y value - so that I will only have to 'test' the x value against the line equation of the turtle's heading. (In the simulated environment there are 4 walls in total - 2 vertical and 2 horizontal)
ask patches with [abs pycor = 10] [set pcolor grey]
ask patches with [abs pycor = 11] [set pcolor grey]
Many thanks in advance for any help/suggestions
--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/ae8482dc-9cc5-4d40-ba35-e9e471bd3808%40googlegroups.com.