Geometry¶
Built-in 3D geometry primitives for surface area calculations, zone volume estimation, and coordinate transforms -- no external geometry dependencies required.
Geometry utilities for IDF models.
Provides coordinate handling and transformations without geomeppy dependency.
Polygon3D
dataclass
¶
3D polygon defined by vertices.
Computes geometric properties (area, normal, tilt, azimuth) and supports transformations (translate, rotate).
Examples:
A 5 m x 4 m ground-floor slab:
>>> floor = Polygon3D([
... Vector3D(0, 0, 0), Vector3D(5, 0, 0),
... Vector3D(5, 4, 0), Vector3D(0, 4, 0),
... ])
>>> floor.area
20.0
>>> floor.is_horizontal
True
A 10 m wide, 3 m high south-facing exterior wall:
>>> south_wall = Polygon3D([
... Vector3D(0, 0, 0), Vector3D(10, 0, 0),
... Vector3D(10, 0, 3), Vector3D(0, 0, 3),
... ])
>>> south_wall.area
30.0
>>> south_wall.tilt
90.0
>>> south_wall.azimuth
180.0
Source code in src/idfkit/geometry.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | |
area
property
¶
azimuth
property
¶
Surface azimuth in degrees (0=north, 90=east, 180=south, 270=west).
Uses the same convention as EnergyPlus / eppy: the angle of the outward normal projected onto the horizontal plane, measured clockwise from north (+Y axis).
Returns 0.0 for perfectly horizontal surfaces (tilt 0 or 180).
Examples:
South-facing wall (normal points toward -Y):
>>> Polygon3D([
... Vector3D(0,0,0), Vector3D(10,0,0),
... Vector3D(10,0,3), Vector3D(0,0,3),
... ]).azimuth
180.0
Horizontal surface has azimuth 0:
centroid
property
¶
is_horizontal
property
¶
is_vertical
property
¶
normal
property
¶
num_vertices
property
¶
tilt
property
¶
Surface tilt angle in degrees.
0 = facing up (horizontal roof/ceiling), 90 = vertical wall, 180 = facing down (horizontal floor). Computed from the surface normal using the same convention as EnergyPlus / eppy.
Examples:
Flat roof (tilt 0 = facing up):
>>> Polygon3D([
... Vector3D(0,0,3), Vector3D(5,0,3),
... Vector3D(5,5,3), Vector3D(0,5,3),
... ]).tilt
0.0
Exterior wall (tilt 90 = vertical):
as_tuple_list()
¶
from_tuples(coords)
classmethod
¶
Create from sequence of coordinate tuples.
Examples:
>>> poly = Polygon3D.from_tuples([(0,0,0), (5,0,0), (5,5,0), (0,5,0)])
>>> poly.area
25.0
>>> poly.num_vertices
4
Source code in src/idfkit/geometry.py
rotate_z(angle_deg, anchor=None)
¶
Rotate around Z axis.
Source code in src/idfkit/geometry.py
translate(offset)
¶
Return translated polygon.
Examples:
>>> tri = Polygon3D([Vector3D(0,0,0), Vector3D(1,0,0), Vector3D(0,1,0)])
>>> moved = tri.translate(Vector3D(10, 20, 0))
>>> moved.centroid
Vector3D(x=10.333333333333334, y=20.333333333333332, z=0.0)
Source code in src/idfkit/geometry.py
Vector3D
dataclass
¶
Immutable 3D vector.
Supports arithmetic operations (+, -, *, /, unary -)
and common vector operations (dot product, cross product, normalization).
Examples:
Vectors support arithmetic:
>>> Vector3D(1, 2, 3) + Vector3D(4, 5, 6)
Vector3D(x=5, y=7, z=9)
>>> Vector3D(3, 0, 0) * 2
Vector3D(x=6, y=0, z=0)
>>> -Vector3D(1, 0, 0)
Vector3D(x=-1, y=0, z=0)
Source code in src/idfkit/geometry.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
as_tuple()
¶
cross(other)
¶
Cross product.
Examples:
>>> Vector3D(1, 0, 0).cross(Vector3D(0, 1, 0))
Vector3D(x=0, y=0, z=1)
>>> Vector3D(3, 0, 0).cross(Vector3D(0, 4, 0))
Vector3D(x=0, y=0, z=12)
Source code in src/idfkit/geometry.py
dot(other)
¶
from_tuple(t)
classmethod
¶
length()
¶
Vector magnitude.
Examples:
normalize()
¶
origin()
classmethod
¶
Return origin vector.
Examples:
rotate_z(angle_deg)
¶
Rotate around Z axis by angle in degrees.
Examples:
>>> v = Vector3D(1, 0, 0).rotate_z(90)
>>> round(v.x, 10), round(v.y, 10)
(0.0, 1.0)
>>> Vector3D(1, 0, 5).rotate_z(180)
Vector3D(x=-1.0, y=0.0, z=5.0)
Source code in src/idfkit/geometry.py
calculate_surface_area(surface)
¶
Calculate the area of a surface in m².
Examples:
Area of a 10 m wide, 3 m high exterior wall:
>>> from idfkit import new_document
>>> model = new_document()
>>> wall = model.add("BuildingSurface:Detailed", "South_Wall",
... surface_type="Wall", construction_name="", zone_name="",
... outside_boundary_condition="Outdoors",
... sun_exposure="SunExposed", wind_exposure="WindExposed",
... number_of_vertices=4,
... vertex_1_x_coordinate=0, vertex_1_y_coordinate=0, vertex_1_z_coordinate=3,
... vertex_2_x_coordinate=0, vertex_2_y_coordinate=0, vertex_2_z_coordinate=0,
... vertex_3_x_coordinate=10, vertex_3_y_coordinate=0, vertex_3_z_coordinate=0,
... vertex_4_x_coordinate=10, vertex_4_y_coordinate=0, vertex_4_z_coordinate=3,
... validate=False)
>>> calculate_surface_area(wall)
30.0
Source code in src/idfkit/geometry.py
calculate_surface_azimuth(surface)
¶
Calculate the azimuth of a surface in degrees (eppy compatibility).
0 = north, 90 = east, 180 = south, 270 = west. Useful for identifying solar exposure for glazing and shading studies.
Examples:
Confirm a wall faces south (azimuth 180):
>>> from idfkit import new_document
>>> model = new_document()
>>> wall = model.add("BuildingSurface:Detailed", "SouthWall",
... surface_type="Wall", construction_name="", zone_name="",
... outside_boundary_condition="Outdoors",
... sun_exposure="SunExposed", wind_exposure="WindExposed",
... number_of_vertices=4,
... vertex_1_x_coordinate=0, vertex_1_y_coordinate=0, vertex_1_z_coordinate=3,
... vertex_2_x_coordinate=0, vertex_2_y_coordinate=0, vertex_2_z_coordinate=0,
... vertex_3_x_coordinate=10, vertex_3_y_coordinate=0, vertex_3_z_coordinate=0,
... vertex_4_x_coordinate=10, vertex_4_y_coordinate=0, vertex_4_z_coordinate=3,
... validate=False)
>>> calculate_surface_azimuth(wall)
180.0
Source code in src/idfkit/geometry.py
calculate_surface_tilt(surface)
¶
Calculate the tilt of a surface in degrees (eppy compatibility).
0 = facing up (roof), 90 = vertical (wall), 180 = facing down (floor).
Examples:
Verify that an exterior wall is vertical:
>>> from idfkit import new_document
>>> model = new_document()
>>> wall = model.add("BuildingSurface:Detailed", "South_Wall",
... surface_type="Wall", construction_name="", zone_name="",
... outside_boundary_condition="Outdoors",
... sun_exposure="SunExposed", wind_exposure="WindExposed",
... number_of_vertices=4,
... vertex_1_x_coordinate=0, vertex_1_y_coordinate=0, vertex_1_z_coordinate=3,
... vertex_2_x_coordinate=0, vertex_2_y_coordinate=0, vertex_2_z_coordinate=0,
... vertex_3_x_coordinate=10, vertex_3_y_coordinate=0, vertex_3_z_coordinate=0,
... vertex_4_x_coordinate=10, vertex_4_y_coordinate=0, vertex_4_z_coordinate=3,
... validate=False)
>>> calculate_surface_tilt(wall)
90.0
Source code in src/idfkit/geometry.py
calculate_zone_ceiling_area(doc, zone_name)
¶
Calculate the total ceiling/roof area of a zone (eppy compatibility).
Sums the area of all surfaces whose surface_type is "Ceiling"
or "Roof" in the given zone.
Examples:
Calculate the ceiling area of a 5 m x 4 m office at z=3 m:
>>> from idfkit import new_document
>>> model = new_document()
>>> model.add("Zone", "Office")
Zone('Office')
>>> model.add("BuildingSurface:Detailed", "Office_Ceiling",
... surface_type="Ceiling", construction_name="", zone_name="Office",
... outside_boundary_condition="Outdoors",
... number_of_vertices=4,
... vertex_1_x_coordinate=0, vertex_1_y_coordinate=0, vertex_1_z_coordinate=3,
... vertex_2_x_coordinate=0, vertex_2_y_coordinate=4, vertex_2_z_coordinate=3,
... vertex_3_x_coordinate=5, vertex_3_y_coordinate=4, vertex_3_z_coordinate=3,
... vertex_4_x_coordinate=5, vertex_4_y_coordinate=0, vertex_4_z_coordinate=3,
... validate=False)
BuildingSurface:Detailed('Office_Ceiling')
>>> calculate_zone_ceiling_area(model, "Office")
20.0
Source code in src/idfkit/geometry.py
calculate_zone_floor_area(doc, zone_name)
¶
Calculate the total floor area of a zone.
Sums the area of all BuildingSurface:Detailed objects whose
surface_type is "Floor" and whose zone_name matches.
Examples:
Calculate the floor area of a 5 m x 4 m office:
>>> from idfkit import new_document
>>> model = new_document()
>>> model.add("Zone", "Office")
Zone('Office')
>>> model.add("BuildingSurface:Detailed", "Office_Floor",
... surface_type="Floor", construction_name="", zone_name="Office",
... outside_boundary_condition="Ground",
... number_of_vertices=4,
... vertex_1_x_coordinate=0, vertex_1_y_coordinate=0, vertex_1_z_coordinate=0,
... vertex_2_x_coordinate=5, vertex_2_y_coordinate=0, vertex_2_z_coordinate=0,
... vertex_3_x_coordinate=5, vertex_3_y_coordinate=4, vertex_3_z_coordinate=0,
... vertex_4_x_coordinate=0, vertex_4_y_coordinate=4, vertex_4_z_coordinate=0,
... validate=False)
BuildingSurface:Detailed('Office_Floor')
>>> calculate_zone_floor_area(model, "Office")
20.0
Source code in src/idfkit/geometry.py
calculate_zone_height(doc, zone_name)
¶
Calculate the height of a zone from its surfaces.
Returns the difference between the maximum and minimum Z coordinates across all surfaces belonging to the zone.
Examples:
Determine the floor-to-ceiling height of a 3 m tall office:
>>> from idfkit import new_document
>>> model = new_document()
>>> model.add("Zone", "Office")
Zone('Office')
>>> model.add("BuildingSurface:Detailed", "South_Wall",
... surface_type="Wall", construction_name="", zone_name="Office",
... outside_boundary_condition="Outdoors",
... sun_exposure="SunExposed", wind_exposure="WindExposed",
... number_of_vertices=4,
... vertex_1_x_coordinate=0, vertex_1_y_coordinate=0, vertex_1_z_coordinate=3,
... vertex_2_x_coordinate=0, vertex_2_y_coordinate=0, vertex_2_z_coordinate=0,
... vertex_3_x_coordinate=5, vertex_3_y_coordinate=0, vertex_3_z_coordinate=0,
... vertex_4_x_coordinate=5, vertex_4_y_coordinate=0, vertex_4_z_coordinate=3,
... validate=False)
BuildingSurface:Detailed('South_Wall')
>>> calculate_zone_height(model, "Office")
3.0
Source code in src/idfkit/geometry.py
calculate_zone_volume(doc, zone_name)
¶
Calculate the volume of a zone from its surfaces.
Uses the divergence theorem to compute volume from surface polygons. Returns 0.0 if the zone has no surfaces.
Source code in src/idfkit/geometry.py
get_surface_coords(surface)
¶
Extract coordinates from a surface object.
Works with BuildingSurface:Detailed, FenestrationSurface:Detailed, etc. Supports both field naming conventions:
- Classic/programmatic:
vertex_1_x_coordinate,vertex_2_x_coordinate, ... - epJSON schema:
vertex_x_coordinate,vertex_x_coordinate_2, ...
Examples:
Extract geometry from a 10 m x 3 m south-facing exterior wall:
>>> from idfkit import new_document
>>> model = new_document()
>>> wall = model.add("BuildingSurface:Detailed", "South_Wall",
... surface_type="Wall", construction_name="", zone_name="",
... outside_boundary_condition="Outdoors",
... sun_exposure="SunExposed", wind_exposure="WindExposed",
... number_of_vertices=4,
... vertex_1_x_coordinate=0, vertex_1_y_coordinate=0, vertex_1_z_coordinate=3,
... vertex_2_x_coordinate=0, vertex_2_y_coordinate=0, vertex_2_z_coordinate=0,
... vertex_3_x_coordinate=10, vertex_3_y_coordinate=0, vertex_3_z_coordinate=0,
... vertex_4_x_coordinate=10, vertex_4_y_coordinate=0, vertex_4_z_coordinate=3,
... validate=False)
>>> poly = get_surface_coords(wall)
>>> poly.area
30.0
>>> poly.azimuth
180.0
Source code in src/idfkit/geometry.py
get_zone_origin(zone)
¶
Get the origin point of a zone.
Examples:
A second-floor zone offset 3.5 m above ground:
>>> from idfkit import new_document
>>> model = new_document()
>>> zone = model.add("Zone", "Floor2_Office",
... x_origin=10.0, y_origin=20.0, z_origin=3.5)
>>> get_zone_origin(zone)
Vector3D(x=10.0, y=20.0, z=3.5)
Source code in src/idfkit/geometry.py
get_zone_rotation(zone)
¶
Get the rotation angle of a zone in degrees.
Examples:
A zone rotated 45 degrees from true north (common for buildings aligned to a street grid):
>>> from idfkit import new_document
>>> model = new_document()
>>> zone = model.add("Zone", "Corner_Office",
... direction_of_relative_north=45.0)
>>> get_zone_rotation(zone)
45.0
Source code in src/idfkit/geometry.py
intersect_match(doc)
¶
Match adjacent surfaces and set boundary conditions.
Scans all BuildingSurface:Detailed walls and identifies pairs
whose polygons are coincident (same plane, overlapping area). For
each matched pair, the boundary conditions are updated so the
surfaces reference each other.
This is the idfkit equivalent of geomeppy's
idf.intersect_match().
The algorithm is O(n²) over exterior walls but uses normal-vector and centroid-distance filters to skip most comparisons quickly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
IDFDocument
|
The document to modify in-place. |
required |
Note
This implementation handles the common case of full-overlap
matching (same-size surfaces on opposite sides of a shared
wall). Partial intersection and surface splitting are not
implemented — use EnergyPlus' ExpandObjects preprocessor
or manual surface definition for complex cases.
Source code in src/idfkit/geometry.py
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 | |
rotate_building(doc, angle_deg, anchor=None)
¶
Rotate all building surfaces around the Z axis.
Only vertex coordinates are modified; Building.north_axis and
Zone rotation fields are not updated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
IDFDocument
|
The document to modify in-place. |
required |
angle_deg
|
float
|
Rotation angle in degrees (positive = counter-clockwise when viewed from above). |
required |
anchor
|
Vector3D | None
|
Point to rotate around. If |
None
|
Source code in src/idfkit/geometry.py
set_surface_coords(surface, polygon)
¶
Set coordinates on a surface object.
Updates vertex fields and number_of_vertices.
Examples:
Shorten a wall from 10 m to 5 m by replacing its vertices:
>>> from idfkit import new_document
>>> model = new_document()
>>> wall = model.add("BuildingSurface:Detailed", "South_Wall",
... surface_type="Wall", construction_name="", zone_name="",
... outside_boundary_condition="Outdoors",
... sun_exposure="SunExposed", wind_exposure="WindExposed",
... number_of_vertices=4,
... vertex_1_x_coordinate=0, vertex_1_y_coordinate=0, vertex_1_z_coordinate=3,
... vertex_2_x_coordinate=0, vertex_2_y_coordinate=0, vertex_2_z_coordinate=0,
... vertex_3_x_coordinate=10, vertex_3_y_coordinate=0, vertex_3_z_coordinate=0,
... vertex_4_x_coordinate=10, vertex_4_y_coordinate=0, vertex_4_z_coordinate=3,
... validate=False)
>>> shorter = Polygon3D.from_tuples([(0,0,0),(5,0,0),(5,0,3),(0,0,3)])
>>> set_surface_coords(wall, shorter)
>>> get_surface_coords(wall).area
15.0
Source code in src/idfkit/geometry.py
set_wwr(doc, wwr, *, construction=None, surface_type='Wall', orientation=None, tolerance=10.0)
¶
Add or replace windows to achieve a target window-wall ratio.
For each exterior wall matching the filter criteria, a single
rectangular sub-surface (FenestrationSurface:Detailed) is
created whose area equals wwr * wall_area. Any existing
FenestrationSurface:Detailed sub-surfaces on matching walls are
removed first.
This is the idfkit equivalent of geomeppy's idf.set_wwr().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
IDFDocument
|
The document to modify in-place. |
required |
wwr
|
float
|
Target window-wall ratio in the range |
required |
construction
|
str | None
|
Name of the window |
None
|
surface_type
|
str
|
Only walls whose |
'Wall'
|
orientation
|
str | None
|
Optional cardinal direction filter — one of
|
None
|
tolerance
|
float
|
Azimuth tolerance in degrees when orientation is given. Defaults to 10°. |
10.0
|
Returns:
| Type | Description |
|---|---|
list[IDFObject]
|
List of newly created |
Raises:
| Type | Description |
|---|---|
ValueError
|
If wwr is not in |
Source code in src/idfkit/geometry.py
978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 | |
translate_building(doc, offset)
¶
Translate all building surfaces by the given offset vector.
Modifies the document in-place, shifting every surface's vertices by offset.
Note
Only vertex coordinates are modified. Zone origin fields
and the Building object are not updated. Use
translate_to_world if you need to collapse zone-relative
coordinates into world coordinates.
Examples:
Reposition a building on its site (e.g., from local to geo-referenced coordinates):
>>> from idfkit import new_document
>>> model = new_document()
>>> wall = model.add("BuildingSurface:Detailed", "South_Wall",
... surface_type="Wall", construction_name="", zone_name="",
... outside_boundary_condition="Outdoors",
... sun_exposure="SunExposed", wind_exposure="WindExposed",
... number_of_vertices=4,
... vertex_1_x_coordinate=0, vertex_1_y_coordinate=0, vertex_1_z_coordinate=3,
... vertex_2_x_coordinate=0, vertex_2_y_coordinate=0, vertex_2_z_coordinate=0,
... vertex_3_x_coordinate=10, vertex_3_y_coordinate=0, vertex_3_z_coordinate=0,
... vertex_4_x_coordinate=10, vertex_4_y_coordinate=0, vertex_4_z_coordinate=3,
... validate=False)
>>> translate_building(model, Vector3D(100, 200, 0))
>>> wall.vertex_1_x_coordinate
100.0
Source code in src/idfkit/geometry.py
translate_to_world(doc)
¶
Translate model from relative to world coordinates.
Applies zone origins and rotations to surface coordinates.