collision2d icon indicating copy to clipboard operation
collision2d copied to clipboard

Box pos is not center.

Open agentabstract opened this issue 5 years ago • 4 comments

The comment on NewBox shows that the position of the box is the center of the box, but it's the top left corner of the box, which is pretty standard. The comment just threw me off.

Great library! You're saving me a bunch of time. -TiM-

agentabstract avatar Apr 29 '19 02:04 agentabstract

Hello!

I do not understand the problem. Could you show some code as an example?

With a test case we can fix either the code or the doc message.

Thank you!

Tarliton avatar May 02 '19 03:05 Tarliton

Sure.

package main

import (
	"fmt"
	"github.com/Tarliton/collision2d"
)

func main(){
	box1:=collision2d.NewBox(collision2d.Vector{X:0,Y:0},16,16)
	polygon1:=box1.ToPolygon()
	fmt.Println(polygon1)
}

The output is:

{Pos:{X:0.000000, Y:0.000000} Offset:{X:0.000000, Y:0.000000} Angle: 0.000000 Points: [{X:0.000000, Y:0.000000} {X:16.000000, Y:0.000000} {X:16.000000, Y:16.000000} {X:0.000000, Y:16.000000} ] CalcPoints: [{X:0.000000, Y:0.000000} {X:16.000000, Y:0.000000} {X:16.000000, Y:16.000000} {X:0.000000, Y:16.000000} ]}

So the points show 0,0 in the top left corner. Instead of 0,0 being the center.

agentabstract avatar May 02 '19 04:05 agentabstract

You know I keep saying top left when really it's bottom left. I'm used to dealing with screens where 0,0 is the top left corner, and max width and height are the bottom right corner.

agentabstract avatar May 02 '19 20:05 agentabstract

The problem is here.
It should use center to calculate those corners.

Tarliton avatar May 10 '19 00:05 Tarliton