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.
Polygon2D = list[tuple[float, float]]
module-attribute
¶
VERTEX_SURFACE_TYPES = ['BuildingSurface:Detailed', 'FenestrationSurface:Detailed', 'Shading:Site:Detailed', 'Shading:Building:Detailed', 'Shading:Zone:Detailed']
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
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 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):
vertices
instance-attribute
¶
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 idfkit/geometry.py
rotate_z(angle_deg, anchor=None)
¶
Rotate around Z axis.
Source code in 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 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 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 | |
x
instance-attribute
¶
y
instance-attribute
¶
z
instance-attribute
¶
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 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 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,
... vertices=[
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 10, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 10, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... ],
... validate=False)
>>> calculate_surface_area(wall)
30.0
Source code in 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,
... vertices=[
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 10, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 10, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... ],
... validate=False)
>>> calculate_surface_azimuth(wall)
180.0
Source code in 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,
... vertices=[
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 10, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 10, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... ],
... validate=False)
>>> calculate_surface_tilt(wall)
90.0
Source code in 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,
... vertices=[
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 4, "vertex_z_coordinate": 3},
... {"vertex_x_coordinate": 5, "vertex_y_coordinate": 4, "vertex_z_coordinate": 3},
... {"vertex_x_coordinate": 5, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... ],
... validate=False)
BuildingSurface:Detailed('Office_Ceiling')
>>> calculate_zone_ceiling_area(model, "Office")
20.0
Source code in 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,
... vertices=[
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 5, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 5, "vertex_y_coordinate": 4, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 4, "vertex_z_coordinate": 0},
... ],
... validate=False)
BuildingSurface:Detailed('Office_Floor')
>>> calculate_zone_floor_area(model, "Office")
20.0
Source code in 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,
... vertices=[
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 5, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 5, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... ],
... validate=False)
BuildingSurface:Detailed('South_Wall')
>>> calculate_zone_height(model, "Office")
3.0
Source code in 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 idfkit/geometry.py
get_surface_coords(surface)
¶
Extract coordinates from a surface object.
Reads from the canonical wrapper array (surface.data["vertices"])
for extensible types like BuildingSurface:Detailed, and falls back
to fixed flat vertex_N_x_coordinate fields for surface types whose
vertex count is fixed in the schema (e.g. FenestrationSurface:Detailed).
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,
... vertices=[
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 10, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 10, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... ],
... validate=False)
>>> poly = get_surface_coords(wall)
>>> poly.area
30.0
>>> poly.azimuth
180.0
Source code in 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 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 idfkit/geometry.py
intersect_match(doc)
¶
Intersect and match adjacent interzone surfaces, splitting as needed.
Coplanar, oppositely-facing surfaces that overlap are split into
congruent matched fragments (interior Surface boundary conditions)
plus exterior remainders. A single surface abutting several smaller
neighbours is split into one matched fragment per neighbour — the
long-wall-shared-with-many-zones case. The document is modified in place.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
IDFDocument
|
The document to modify in-place. |
required |
Note
This is a thin wrapper over
intersect_and_match,
which returns a
MatchReport and accepts a
MatchOptions for tuning
tolerances and scope. Call it directly when you need either.
Source code in idfkit/geometry.py
is_convex_2d(poly, *, eps=1e-12)
¶
Return True if the 2-D polygon is convex.
Source code in idfkit/geometry.py
line_intersect_2d(a1, a2, b1, b2, *, eps=1e-12)
¶
Intersection of two infinite lines through (a1, a2) and (b1, b2).
Source code in idfkit/geometry.py
polygon_area_2d(poly)
¶
Signed area of a 2-D polygon (positive = CCW).
Source code in idfkit/geometry.py
polygon_contains_2d(outer, inner)
¶
Return True if all vertices of inner are inside outer.
Source code in idfkit/geometry.py
polygon_difference_2d(outer, inner)
¶
Subtract inner from outer using a bridge/slit polygon.
The inner polygon must be fully contained within outer. Both
must be counter-clockwise. Returns a single simple (non-convex)
polygon representing the frame region, or None if the inner
polygon covers the entire outer polygon.
The approach is the same slit technique used by
:func:~idfkit.zoning.footprint_courtyard.
Source code in idfkit/geometry.py
polygon_intersection_2d(poly_a, poly_b)
¶
Compute the intersection of two 2-D polygons.
Uses the Sutherland-Hodgman algorithm. At least one polygon must be
convex (the convex one is used as the clip polygon). If both are
concave the function returns None.
Returns:
| Type | Description |
|---|---|
Polygon2D | None
|
The intersection polygon vertices, or |
Polygon2D | None
|
both polygons are concave. |
Source code in idfkit/geometry.py
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 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,
... vertices=[
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 10, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 10, "vertex_y_coordinate": 0, "vertex_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 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 idfkit/geometry.py
1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 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 | |
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,
... vertices=[
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 10, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 10, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... ],
... validate=False)
>>> translate_building(model, Vector3D(100, 200, 0))
>>> wall.vertices[0].vertex_x_coordinate
100.0
Source code in idfkit/geometry.py
translate_to_world(doc)
¶
Rewrite every detailed surface's vertices into the frame the engine computes, in place.
This is the mutating counterpart of get_scene, and it is that function that does the work: the polygons written back here are the ones the scene resolved, so the two cannot drift apart. The document, and not a copy, is what changes, which is what this function is for.
BEHAVIOUR CHANGE, WITH THE MEASUREMENT THAT PROMPTED IT
Until idfkit 1.0.0-rc.6 this function resolved coordinates by a rule that disagreed with
EnergyPlus. Against the engine's own Output:Surfaces:List vertex report over seventeen of the
shipped example models and five hundred and thirty-two surfaces, the old rule agreed with the
engine on five of the seventeen models, worst case 201.98 m of displacement. The rule it
now applies agrees on seventeen of seventeen, worst case 0.0045 m, against a report that
prints two decimals. Three defects account for the difference:
- It rotated each surface by
Building.north_axisinside its own zone frame, about the polygon's centroid. The engine turns the resolved building as one body about the world origin, and in the opposite sense: the north axis is measured clockwise from true north. Each surface therefore came out correctly oriented with its zone in the wrong place, a drawing that passes an eyeball test at up to 201.98 m of error. - It translated by the zone origin without rotating that origin by the building axis first, so the two clauses composed in the wrong order.
- It collected a zone's surfaces with
get_referencing(zone_name), which fenestration never matches: a window names its parent wall and not the zone, so no window was ever moved.
The same defects measured on the corpus's own fixture set, which is what
checks/geometry-vertices in idfkit-conformance now runs this function against: the old
rule failed 60 of the 234 surfaces over four of the seven fixtures, worst case 40.00 m,
and left a fifth unreadable by declaring the world system while leaving clockwise entry in
place. The corrected rule fails none of them.
Two further differences follow from the corrected rule rather than from a defect. A model
declaring World is no longer returned from untouched: the building north axis applies to such
a model too, and only the zone origin and the zone's relative north are conditional on the
relative system. And a model declaring clockwise vertex entry has its rings reversed, the first
vertex held in place, with GlobalGeometryRules restated as counter-clockwise, so that the
right-hand rule gives the outward normal in the result.
WHAT IT DOES NOT TOUCH, WHICH MATTERS FOR A MIXED MODEL
Only the five detailed vertex types are read: BuildingSurface:Detailed,
FenestrationSurface:Detailed and the three detailed shading forms. The simplified surface
family (Wall:Exterior, Window, Roof and their siblings) and
Daylighting:ReferencePoint state their geometry against the zone origin under their own
coordinate-system fields, which this function does not read and cannot transform. Zeroing
Building.north_axis at the end therefore leaves such objects unrotated in a document that no
longer declares the rotation. A model holding both families is outside what this function can
make consistent; get_scene reports the types it did not attempt
instead of editing the document, and is the better tool there.
An object the scene could not place is not rewritten either, for the same reason and with the
same consequence: its vertices stay as the author wrote them while the declarations they were
written against are restated underneath it. Each one is logged at warning level, and
get_scene names them with a reason in Scene.unresolved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
IDFDocument
|
the document to rewrite. Every surface the scene resolved has its vertices replaced, and the declarations those vertices were resolved against are restated so that reading the result back applies nothing a second time. |
required |
Examples:
A zone at (10, 20, 0) with one wall authored at the zone's own origin:
>>> from idfkit import new_document
>>> model = new_document(version=(24, 1, 0))
>>> rules = model["GlobalGeometryRules"].first()
>>> rules.coordinate_system = "Relative"
>>> zone = model.add("Zone", "Office", x_origin=10.0, y_origin=20.0, z_origin=0.0)
>>> wall = model.add("BuildingSurface:Detailed", "OfficeWall",
... surface_type="Wall", zone_name="Office",
... outside_boundary_condition="Outdoors", number_of_vertices=3,
... vertices=[
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 3},
... {"vertex_x_coordinate": 0, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... {"vertex_x_coordinate": 5, "vertex_y_coordinate": 0, "vertex_z_coordinate": 0},
... ],
... validate=False)
>>> translate_to_world(model)
>>> get_surface_coords(wall).vertices[0]
Vector3D(x=10.0, y=20.0, z=3.0)
>>> rules.coordinate_system
'World'
Source code in idfkit/geometry.py
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 | |