class CP::Shape::Segment

Overview

A line segment shape between two points.

Meant mainly as a static shape. Can be beveled in order to give them a thickness.

Defined in:

chipmunk/shape.cr
chipmunk/unsafe.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class CP::Shape

area : Float64 area, bb : BB bb, body : Body | Nil body, body=(body : Body | Nil) body=, cache_bb : BB cache_bb, center_of_gravity : Vect center_of_gravity, collide(b : Shape) : ContactPointSet collide, collision_type : CollisionType collision_type, collision_type=(collision_type : Int) collision_type=, density : Float64 density, density=(density : Number) density=, elasticity : Float64 elasticity, elasticity=(elasticity : Number) elasticity=, filter : ShapeFilter filter, filter=(filter : ShapeFilter) filter=, friction : Float64 friction, friction=(friction : Number) friction=, mass : Float64 mass, mass=(mass : Number) mass=, moment : Float64 moment, point_query(p : Vect) : PointQueryInfo point_query, segment_query(a : Vect, b : Vect, radius : Number = 0) : SegmentQueryInfo | Nil segment_query, sensor=(sensor : Bool) sensor=, sensor? : Bool sensor?, space : Space | Nil space, surface_velocity : Vect surface_velocity, surface_velocity=(surface_velocity : Vect) surface_velocity=, update(transform : Transform) : BB update

Constructor Detail

def self.new(body : Body | Nil, a : Vect, b : Vect, radius : Number = 0) #

The parameters are: the body to attach the segment to; the endpoints (a, b) to attach the segment to; the radius of the half-circles at the ends of the segment (thickness is twice the radius).


[View source]

Class Method Detail

def self.area(a : Vect, b : Vect, radius : Number) : Float64 #

Calculate the area of a fattened (capsule shaped) line segment.


[View source]
def self.moment(m : Number, a : Vect, b : Vect, radius : Number = 0) : Float64 #

Calculate the moment of inertia for a line segment.

Beveling radius is not supported.


[View source]

Instance Method Detail

def a : Vect #

Get the first endpoint of a segment shape.


[View source]
def b : Vect #

Get the second endpoint of a segment shape.


[View source]
def normal : Vect #

Get the normal of a segment shape.


[View source]
def radius : Float64 #

Get the radius of a segment shape.


[View source]
def radius=(radius : Number) #

Unsafe. Set the radius of a segment shape.

This change is only picked up as a change to the position of the shape's surface, but not its velocity. Changing it will not result in realistic physical behavior. Only use if you know what you are doing!


[View source]
def set_endpoints(a : Vect, b : Vect) #

Unsafe. Set the endpoints of a segment shape.

This change is only picked up as a change to the position of the shape's surface, but not its velocity. Changing it will not result in realistic physical behavior. Only use if you know what you are doing!


[View source]
def set_neighbors(prev : Vect, next next_ : Vect) #

Let Chipmunk know about the geometry of adjacent segments to avoid colliding with endcaps.

When you have a number of segment shapes that are all joined together, things can still collide with the "cracks" between the segments. By setting the neighbor segment endpoints you can tell Chipmunk to avoid colliding with the inner parts of the crack.


[View source]