Giter Site home page Giter Site logo

Box pos is not center. about collision2d HOT 4 OPEN

tarliton avatar tarliton commented on May 14, 2024
Box pos is not center.

from collision2d.

Comments (4)

Tarliton avatar Tarliton commented on May 14, 2024

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!

from collision2d.

agentabstract avatar agentabstract commented on May 14, 2024

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.

from collision2d.

agentabstract avatar agentabstract commented on May 14, 2024

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.

from collision2d.

Tarliton avatar Tarliton commented on May 14, 2024

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

from collision2d.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.