class
   CP::Shape::Segment
  
  - CP::Shape::Segment
- CP::Shape
- Reference
- Object
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.crchipmunk/unsafe.cr
Constructors
- 
        .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). 
Class Method Summary
- 
        .area(a : Vect, b : Vect, radius : Number) : Float64
        
          Calculate the area of a fattened (capsule shaped) line segment. 
- 
        .moment(m : Number, a : Vect, b : Vect, radius : Number = 0) : Float64
        
          Calculate the moment of inertia for a line segment. 
Instance Method Summary
- 
        #a : Vect
        
          Get the first endpoint of a segment shape. 
- 
        #b : Vect
        
          Get the second endpoint of a segment shape. 
- 
        #normal : Vect
        
          Get the normal of a segment shape. 
- 
        #radius : Float64
        
          Get the radius of a segment shape. 
- 
        #radius=(radius : Number)
        
          Unsafe. Set the radius of a segment shape. 
- 
        #set_endpoints(a : Vect, b : Vect)
        
          Unsafe. Set the endpoints of a segment shape. 
- 
        #set_neighbors(prev : Vect, next next_ : Vect)
        
          Let Chipmunk know about the geometry of adjacent segments to avoid colliding with endcaps. 
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
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).
Class Method Detail
Calculate the area of a fattened (capsule shaped) line segment.
Calculate the moment of inertia for a line segment.
Beveling radius is not supported.
Instance Method Detail
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!
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!
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.