{"id":13832250,"url":"https://github.com/pygae/cppganja","last_synced_at":"2025-07-09T16:34:44.607Z","repository":{"id":87256279,"uuid":"198402292","full_name":"pygae/cppganja","owner":"pygae","description":"C++ geometric algebra visualisation via ganja.js","archived":false,"fork":false,"pushed_at":"2020-01-16T15:07:48.000Z","size":125,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-20T14:47:52.040Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pygae.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-07-23T09:53:05.000Z","updated_at":"2024-02-16T15:15:22.000Z","dependencies_parsed_at":"2023-05-12T21:00:46.744Z","dependency_job_id":null,"html_url":"https://github.com/pygae/cppganja","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pygae/cppganja","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pygae%2Fcppganja","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pygae%2Fcppganja/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pygae%2Fcppganja/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pygae%2Fcppganja/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pygae","download_url":"https://codeload.github.com/pygae/cppganja/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pygae%2Fcppganja/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264495108,"owners_count":23617496,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T10:01:57.083Z","updated_at":"2025-07-09T16:34:42.582Z","avatar_url":"https://github.com/pygae.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# cppganja - C++ interface to ganja.js\nA very simple/limited interface to [ganja.js](https://github.com/enkimute/ganja.js) written for c++\n\n# Interface example\n\n```\n// A couple of example CGA objects\nstd::vector\u003cdouble\u003e test_obj{0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,4.23135483,4.23135483,0.48031496,0.48031496,0.95680003,1.2228812,1.2228812,-0.06350011,-0.28372776,0.,0.,0.,0.,0.,0.};\nstd::vector\u003cdouble\u003e test_obj2{0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,-0.08525168,3.49464756,3.52703718,-1.59496133,-1.62835966,0.76309611,0.64874369,0.65012918,0.18968262,-0.22823195,0.,0.,0.,0.,0.,0.};\n\n// Make the scene and add the objects\nGanjaScene gs = GanjaScene();\ngs.add_object(test_obj);\ngs.add_object(test_obj2, Color::RED);\n\n// State what signature our algebra is from \nstd::vector\u003cdouble\u003e sig{1.0,1.0,1.0,1.0,-1.0};\nstd::string html = generate_full_html(gs.as_string(), sig, 0.1);\n\n// Write the output to an html file\nstd::ofstream myfile;\nmyfile.open (\"example.html\");\nmyfile \u003c\u003c html;\nmyfile.close();\n```\n\n![Interface example](./ExampleImage.png?raw=true)\n\n# Ganja.js generated C++ Example\n\n```\n\n#include \u003ciostream\u003e\n#include \u003ctime.h\u003e\n#include \"cga.h\"\n#include \"../../GanjaScene.h\"\n\n\n// Convenience function to get a double in the range a -\u003e b\ndouble rand_float_range(double a, double b){\n    return ((b - a) * ((double)rand() / RAND_MAX)) + a;\n}\n\n\n// Convenience function to get a random point near the origin\nCGA random_point(double scale=1){\n    return up(rand_float_range(-scale, scale), \n    \trand_float_range(-scale, scale), \n    \trand_float_range(-scale, scale));\n}\n\n\n// Convenience function to get a random line near the origin\nCGA random_line(double scale=1){\n    return (random_point(scale)^random_point(scale)^ni).normalized();\n}\n\n\n// Convenience function to get a random circle near the origin\nCGA random_circle(double scale=1){\n    return (random_point(scale)^random_point(scale)^random_point(scale)).normalized();\n}\n\n\n// Convenience function to get a random plane near the origin\nCGA random_plane(double scale=1){\n    return (random_point(scale)^random_point(scale)^random_point(scale)^ni).normalized();\n}\n\n\nint main (int argc, char **argv) {\n\n\t// We will seed the RNG to get different results\n    unsigned int  seed = time(NULL);\n    srand (seed);\n\n    // Print the seed in case we like the look \n    // of the scene and want to recreate\n    std::cout \u003c\u003c \"Seed: \" \u003c\u003c seed \u003c\u003c std::endl;\n\n    // Ok lets make some objects\n    CGA point = random_point();\n    CGA line = random_line();\n    CGA circle = random_circle();\n    CGA plane = random_plane();\n\n    // Make the GanjaScene and add the objects to it\n\tGanjaScene gs = GanjaScene();\n\tgs.add_object(point, Color::BLACK); // You can specify color explicitly\n\tgs.add_object(line, Color::RED);\n\tgs.add_object(circle, Color::BLUE);\n\tgs.add_object(plane); // Or allow it to default to a semi-see-through grey\n\n\t// State what signature our algebra is from \n\tstd::vector\u003cdouble\u003e sig{1.0,1.0,1.0,1.0,-1.0};\n\tstd::string html = generate_full_html(gs.as_string(), sig);\n\n\t// Write the output to an html file\n\tstd::ofstream myfile;\n\tmyfile.open (\"example.html\");\n\tmyfile \u003c\u003c html;\n\tmyfile.close();\n\n\n  return 0;\n}\n```\n![Ganja cpp example 2](./ExampleImage2.png?raw=true)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpygae%2Fcppganja","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpygae%2Fcppganja","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpygae%2Fcppganja/lists"}