diff --git a/doc/howtos/python_api_introduction/python_api_introduction.md b/doc/howtos/python_api_introduction/python_api_introduction.md index ac52891eb..b7e06cc5b 100644 --- a/doc/howtos/python_api_introduction/python_api_introduction.md +++ b/doc/howtos/python_api_introduction/python_api_introduction.md @@ -192,6 +192,75 @@ Output: >>> 207422.1875 ``` +### `gom_vec3d` and `gom_math` + +The Python module `gom_vec3d` defines the classes `gom.Vec3d` and `Point3d`. `gom.Vec3d` objects are used to represent single coordinates, such as a circle's center or a point, e.g. + +```python +print(gom.app.project.nominal_elements['Circle 1'].center_coordinate) +# Output: +# gom.Vec3d (10.0, -10.0, 0.0) +``` + +The Python module `gom_math` provides some utility functions for geometrical computations on `gom.Vec3d` objects. + +To list the contents of `gom_vec3d`: + +```python +import gom +import gom_math + +items = dir(gom_math) + +print ("gom_math contents:") +for item in items: + print (item) + +# Output: +# Plane3d_distance_to_point +# Plane3d_getDirection1 +# Plane3d_intersectWithLine +# Plane3d_intersectWithPlane +# Plane3d_perpendPoint +# Vec3d_cross +# Vec3d_div +# ... +``` + +To get a function's documentation, e.g. for `gom_math.Vec3d_mult_scalar`: + +```python +print(gom_math.Vec3d_mult_scalar.__doc__) + +# Output: +# Multiplies each component of a Gom.Vec3d vector by a scalar. +# +# Args: +# vec (Gom.Vec3d): The input Gom.Vec3d vector. +# scalar (float): The scalar value to multiply with. +# +# Returns: +# Gom.Vec3d: The result of scalar multiplication of the vector. +``` + +Example: +```python +x = 1 +y = 2 +z = 3 +multiplier = 1.5 + +vector = gom.Vec3d(x, y, z) +print(gom_math.Vec3d_mult_scalar(vector, multiplier)) + +# Output: +# gom.Vec3d (1.5, 3.0, 4.5) +``` + +The Python files `gom_vec3d.py` and `gom_math.py` are located in `C:\Program Files\Zeiss\INSPECT\2025\lib\python\gom-python`. + +For more complex operations or efficient handling of large sets of data, the [NumPy](https://numpy.org/) package is recommended. + ### Element properties in VSCode Using Visual Studio Code, you can get auto-completion for the usable keywords directly in a pop-up. diff --git a/doc/index.md b/doc/index.md index 28a7c8a29..6003931bf 100644 --- a/doc/index.md +++ b/doc/index.md @@ -40,6 +40,8 @@ Check out the ZEISS INSPECT Apps news page! .. toctree:: :hidden: + news/20250123-gom-math + news/20250106-app-doc-link news/20241217-scripted-diagrams news/20241211-services news/20241205-autodialogcontext diff --git a/doc/news/20250123-gom-math.md b/doc/news/20250123-gom-math.md new file mode 100644 index 000000000..246a065bb --- /dev/null +++ b/doc/news/20250123-gom-math.md @@ -0,0 +1,10 @@ +# Using the `gom_vec3d` and `gom_math` modules + +```{eval-rst} +.. feed-entry:: + :date: 2025-01-32 11:00 +``` + +Did you know? Coordinates are often represented in ZEISS INSPECT Apps as `gom.Vec3d` objects. The `gom_math` module provides some functions for computations on `gom.Vec3d` objects. + +See <a href="../howtospython_api_introduction/python_api_introduction.html#gom_vec3d-and-gom_math">ZEISS INSPECT Python API Introduction — `gom_vec3d` and `gom_math`</a> for details. diff --git a/doc/news/news.md b/doc/news/news.md index d2e7fad4f..b88a2a552 100644 --- a/doc/news/news.md +++ b/doc/news/news.md @@ -15,6 +15,8 @@ myst: :title: ZEISS INSPECT 2025 App Python API News :link: https://zeissiqs.github.io/zeiss-inspect-addon-api/2025/ + 20250123-gom-math + 20250106-app-doc-link 20241217-scripted-diagrams 20241211-services 20241205-autodialogcontext