Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/vector plane class #11

Merged
merged 21 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,22 @@ name: Publish CwMath Package
on:
push:
branches:
- main
paths:
- 'src/**'
- 'setup.py'
- 'main'

jobs:
build-and-publish:
name: Build and Publish
runs-on: ubuntu-20.04

runs-on: 'ubuntu-latest'
environment:
name: pypi
url: https://pypi.org/p/cwmath
permissions:
id-token: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9
- run: >-
python -m
pip install
build
--user
- run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
python-version: '3.10'
- run: pip install build
- run: python -m build
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
39 changes: 14 additions & 25 deletions .github/workflows/test_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,25 @@ name: Test Publish CwMath Package

on:
push:
branches:
- develop
paths:
- 'src/**'
- 'setup.py'
branches-ignore:
- 'main'

jobs:
build-and-publish:
name: Test Build and Publish
runs-on: ubuntu-20.04

runs-on: 'ubuntu-latest'
environment:
name: testpypi
url: https://test.pypi.org/p/cwmath
permissions:
id-token: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9
- run: >-
python -m
pip install
build
--user
- run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
python-version: '3.10'
- run: pip install build
- run: python -m build
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/
21 changes: 21 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Python Math Tests

on:
pull_request:
branches:
- main

jobs:
run-math-tests:
name: Run Math Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12
- run: python -m pip install --upgrade pip
- run: pip install pip-tools
- run: pip-sync
- run: python -m pytest
98 changes: 95 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,103 @@ __pycache__/
*.py[cod]
*$py.class

venv/
*.so

.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

*.manifest
*.spec

pip-log.txt
pip-delete-this-directory.txt

htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

*.mo
*.pot

*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

instance/
.webassets-cache

.scrapy

docs/_build/

.pybuilder/
target/

.ipynb_checkpoints

profile_default/
ipython_config.py

.pdm.toml

__pypackages__/

celerybeat-schedule
celerybeat.pid

*.sage.py

.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

.spyderproject
.spyproject

.ropeproject

/site

.mypy_cache/
.dmypy.json
dmypy.json

.pyre/

.pytype/

cython_debug/

.idea/
site/
venv.zip
.vscode/
4 changes: 4 additions & 0 deletions .pip-tools.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tool.pip-tools]
generate-hashes = true
allow-unsafe = true
strip-extras = true
6 changes: 3 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: 2

build:
os: ubuntu-20.04
os: ubuntu-lts-latest
tools:
python: "3.9"
python: "3.12"

mkdocs:
configuration: mkdocs.yml

python:
install:
- requirements: docs/requirements.txt
- requirements: requirements.txt
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Cadwork Informatique Inc.
Copyright (c) 2024 Cadwork

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![Logo](https://filehost.cadwork.ca/cadwork_logo.png)

# Cadwork Math Utilities

[![PyPI](https://img.shields.io/pypi/v/cwmath)](https://pypi.python.org/pypi/cwmath/)
Expand Down Expand Up @@ -74,3 +76,35 @@ do_two()
do_three()

```

# Examples
```python
import cadwork
import element_controller as ec
import geometry_controller as gc

import sys

sys.path.append("...\\...\cwmath\\src")

from cwmath import cwplane3d
from cwmath import cwvector3d

element_ids = ec.get_active_identifiable_element_ids()
if len(element_ids) > 0:
point1 = gc.get_p1(*element_ids)
point2 = gc.get_p2(*element_ids)
yl = gc.get_yl(*element_ids)
plane = cwplane3d.CwPlane3d(point1,yl)
print(point1)
print(yl)
print(plane)

distance = plane.distance_to_point(cadwork.point_3d(0.,0.,0.))
print(distance)

vector1 = cwvector3d.CwVector3d.from_point_3d(point1)
vector2 = cwvector3d.CwVector3d.from_point_3d(point2)
norm =(vector2 - vector1).normalize()
print(norm)
```
2 changes: 1 addition & 1 deletion docs/functions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# CwMath

::: cwmath.cwmath
::: src.cwmath.cwexamples
options:
show_source: true
6 changes: 6 additions & 0 deletions docs/plane3d.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# CwPlane3d

::: src.cwmath.cwplane3d
options:
show_root_heading: true
show_source: true
3 changes: 0 additions & 3 deletions docs/requirements.in

This file was deleted.

78 changes: 0 additions & 78 deletions docs/requirements.txt

This file was deleted.

Loading