JSim 2026.06.01-p(1)
Loading...
Searching...
No Matches
field_wall.hpp
Go to the documentation of this file.
1// Copyright (c) JSim contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the LGPLv3 license file in the root directory of this project.
4
5#pragma once
6
7#include <algorithm>
8#include <array>
9
11
12namespace frcsim {
13
25struct FieldWall {
42 static std::array<FieldObstacle, 4> makeAxisAlignedPerimeter(
43 const Vector3& min_corner_m, const Vector3& max_corner_m,
44 double wall_height_m, double restitution = 0.25, double friction = 0.6) {
45 const double mid_x = 0.5 * (min_corner_m.x + max_corner_m.x);
46 const double mid_y = 0.5 * (min_corner_m.y + max_corner_m.y);
47 const double half_x = 0.5 * (max_corner_m.x - min_corner_m.x);
48 const double half_y = 0.5 * (max_corner_m.y - min_corner_m.y);
49 const double half_h = std::max(0.05, 0.5 * wall_height_m);
50
51 return {
52 FieldObstacle::makeBox(Vector3(mid_x, min_corner_m.y, half_h),
53 Vector3(half_x, 0.05, half_h), Quaternion(),
54 restitution, friction),
55 FieldObstacle::makeBox(Vector3(mid_x, max_corner_m.y, half_h),
56 Vector3(half_x, 0.05, half_h), Quaternion(),
57 restitution, friction),
58 FieldObstacle::makeBox(Vector3(min_corner_m.x, mid_y, half_h),
59 Vector3(0.05, half_y, half_h), Quaternion(),
60 restitution, friction),
61 FieldObstacle::makeBox(Vector3(max_corner_m.x, mid_y, half_h),
62 Vector3(0.05, half_y, half_h), Quaternion(),
63 restitution, friction),
64 };
65 }
66};
67
68} // namespace frcsim
Definition vector.hpp:13
static FieldObstacle makeBox(const Vector3 &center_m, const Vector3 &half_extents_m, const Quaternion &orientation=Quaternion(), double restitution=0.3, double friction=0.6, int user_id=0)
Creates an oriented box obstacle.
Definition obstacle.hpp:73
Helper factory for perimeter wall obstacles.
Definition field_wall.hpp:25
static std::array< FieldObstacle, 4 > makeAxisAlignedPerimeter(const Vector3 &min_corner_m, const Vector3 &max_corner_m, double wall_height_m, double restitution=0.25, double friction=0.6)
Creates four axis-aligned box walls around a rectangular field footprint.
Definition field_wall.hpp:42
Unit-quaternion rotation representation and rotation algebra helpers.
Definition quaternion.hpp:25
3D vector utility used throughout JSim physics.
Definition vector.hpp:22
double x
X component.
Definition vector.hpp:24
double y
Y component.
Definition vector.hpp:26