Hello @SuvrangshuBarua,
For any triangle defined by three JBeam nodes, the usual approach is to read current world positions for those nodes (for example via BeamNGpy Vehicle.get_node_info) and apply the standard 3D formula for triangle area. Summing over triangles gives total surface area for the connectivity you use.
1. Geometry: triangle area (essential math)
def triangle_area_m2(
p1: tuple[float, float, float],
p2: tuple[float, float, float],
p3: tuple[float, float, float],
) -> float:
"""Area = 0.5 * |(p2 - p1) x (p3 - p1)| (m^2)."""
a = np.asarray(p2, dtype=float) - np.asarray(p1, dtype=float)
b = np.asarray(p3, dtype=float) - np.asarray(p1, dtype=float)
return 0.5 * float(np.linalg.norm(np.cross(a, b)))
p1, p2, p3 must be live positions from the simulation if you want the deformed state; static coordinates from the JBeam file alone describe the authored rest pose.
2. Bridge to the simulation: from BeamNGpy get_node_info API
def measure_triangle_area(vehicle: Vehicle, node_names: tuple[str, str, str]) -> float:
infos = vehicle.get_node_info(list(node_names))
if len(infos) != 3:
raise RuntimeError(f"Expected 3 nodes, got {len(infos)}")
positions = [tuple(n["pos"]) for n in infos]
return triangle_area_m2(positions[0], positions[1], positions[2])
get_node_info returns current pos in world space (metres) for each requested node name. That is what ties the geometry above to whatever the physics has produced at that moment (intact part vs buckled/collapsed, etc.).
Important: those positions reflect the simulation state at the time of sampling. If the part is undamaged, the computed area matches that pose. If the structure has buckled or collapsed, the same three nodes with updated positions describe the deformed surface, not the original rest geometry.
BeamNG does not expose triangle surface area as a single built-in âreadoutâ in the Tech/Lua layer; you typically combine triangle connectivity (e.g. from your JBeam that return index triplets) with live node positions, then compute area as above.
Kind regards,
Abdulrahman Saeed
Research Software Engineer
BeamNG.tech Support Team