Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6601873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:48:33+00:00 2026-05-25T18:48:33+00:00

I created a polygon which has 5 vertices, and all vertices are generated by

  • 0

I created a polygon which has 5 vertices, and all vertices are generated by VertexHelper.

Why does the program get SIGABRT at b2Assert(area > b2_epsilon) in ComputeCentroid() in b2PolygonShape.cpp?

The program runs well when I use shape.SetAsBox(.359375, 1.0) instead of shape.Set(vertices, count).

It seems that somethings wrong during calculating centroid when shape.Set() is used, but I don’t know how to deal with this problem.

Here’s the code:

b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.awake = NO;
bodyDef.position.Set(3.125, 3.125);
bodyDef.angle = -.785398163397;
spriteBody = world->CreateBody(&bodyDef);
spriteBody->SetUserData(sprite);
b2MassData massData = {2.0, b2Vec2(0.021875, 0.203125), 0.0};
spriteBody->SetMassData(&massData);
int32 count = 5;
b2Vec2 vertices[] = {
    b2Vec2(-11.5f / PTM_RATIO, -16.0f / PTM_RATIO),
    b2Vec2(-10.5f / PTM_RATIO, 15.0f / PTM_RATIO),
    b2Vec2(10.5f / PTM_RATIO, 15.0f / PTM_RATIO),
    b2Vec2(10.5f / PTM_RATIO, -5.0f / PTM_RATIO),
    b2Vec2(-5.5f / PTM_RATIO, -16.0f / PTM_RATIO)
};
b2PolygonShape shape;
shape.Set(vertices, count);
b2FixtureDef fixtureDef;
fixtureDef.shape = &shape;
fixtureDef.density = 1.0f;
fixtureDef.friction = 0.2f;
fixtureDef.restitution = 0.7f;
spriteBody->CreateFixture(&fixtureDef);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:48:34+00:00Added an answer on May 25, 2026 at 6:48 pm

    It looks like you’ve wound your vertices the wrong way. I think they should be anticlockwise in box2d, at least by default.

    You’re assertion will be failing because the calculation for area will be returning a negative value, far less than b2_epsilon

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a program using dev-cpp and wxwidgets which solves a puzzle. The user
Created .NET WCF service, tested it - works. Generated schemas from Data and service
I have a a polygon class which stores a list of Microsoft.Xna.Framework.Vector2 as the
I have a System.Windows.Controls.Canvas on to which I programatically place a System.Windows.Shapes.Polygon: private Canvas
I would like to deconstruct the following polygon shown in blue removing all of
I have the following code which has been passed on to me and creates
Given a polygon, created entirely from rectangles, and defined by an array of points,
I have a MainController, it creates an object(say polygon), a controller(say,polygonViewController). PolygonViewController has two
How do I take a set of polygons which contain arbitrary values and create
I'm trying to create a fast 2D point inside polygon algorithm, for use in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.