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

Add a basic Sphere3D element #631

Merged
merged 3 commits into from
Mar 15, 2024
Merged

Conversation

Vectornaut
Copy link

Summary

This addresses #616 by adding an element, Sphere3D, representing a sphere in 3D space. It also adds a usage example, sphere3d.html.

Implementation

The interface is based on Circle, but I use ideas from Line3D and ParametricSurface3D to link the 3D geometric representation to the 2D display representation (stored in element2D).

Pitfalls

  • In the example, the lack of depth cues makes it hard to see where the control points are in relation to the sphere.
  • My implementation of Sphere3D isn't consistent with the elements it's based on, because those elements aren't implemented consistently with each other. For example:
    • To measure the distance between points, Circle uses the CoordsElement.Dist method that Point inherits. However, there's no 3D analogue of CoordsElement: the class Point3D descends directly from GeometryElement. I therefore added a distance function, Point3D.distance, directly to the Point3D class.
    • The new type check function isPointType3D is inconsistent with both the 2D analogue isPointType, and it also doesn't match the type check done in createLine3D. Ideally, it would be nice to use the same type check for createSphere3D and createLine3D, but I don't understand the latter well enough to change it.

Aaron Fenyes added 2 commits March 12, 2024 03:20
The radius of the parallel projection circle looks accurate, but the
lack of depth cues makes it hard to see where the control points are in
relation to the sphere.
@Vectornaut Vectornaut changed the title Sphere3d Add a basic Sphere3D element Mar 14, 2024
@alfredwassermann alfredwassermann merged commit 690d05c into jsxgraph:develop Mar 15, 2024
2 of 3 checks passed
@alfredwassermann
Copy link
Member

Thanks a lot, this is very helpful! You probably saw that there is a lot of work ahead for 3D ...

The 2D CoordsElement contains methods which can be used for points, images and texts The position of these elements consist of a single coordinate array. There is no analog (yet) in 3D, so it does not exist yet.

The problem with isPointType and now also with isPointType3D is that internally we work with homogeneous coordinates (i.e. in 3D these are arrays of length 4) but from the users we mostly require affine coordinates (i.e. in 3D an array of length 3). Therefore, the test with >.

@Vectornaut
Copy link
Author

The problem with isPointType and now also with isPointType3D is that internally we work with homogeneous coordinates (i.e. in 3D these are arrays of length 4) but from the users we mostly require affine coordinates (i.e. in 3D an array of length 3). Therefore, the test with >.

If it's worth refactoring these a bit, I can put that on my to-do list. I'd just need to know more about what the desired behavior is: I couldn't find any isPointType unit tests, so I'm not totally sure what should count as point type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants