Commit 200074e4 authored by guillaume's avatar guillaume

triangle visualisation of edges

parent cd2ad1d2
......@@ -11,6 +11,13 @@ Projet conçu pour une compilation avec GCC et la librairie Raylib. De par la na
⚠️ Bien prendre le temps de lire la section d'installation qui vous concerne ⚠️
```mermaid
graph TD;
Antho-->Bobby;
Antho-->Clariss;
Bobby-->Dede;
Clariss-->Dede;
```
### Linux (Debian based, *e.g.* Ubuntu) - Fortement recommandé
---
......
#include "controlpanel.h"
#include "raylib.h"
#include "raymath.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
// Tools
void printVector2( Vector2 v )
{
printf( "[%3f, %3f]", v.x, v.y );
}
// Constructor / Destructor
Panel * Panel_new()
{
......@@ -86,7 +93,15 @@ void Panel_drawEdge(Panel * self, Edge * e)
Vector2 source= Panel_pixelFromPosition(self, &(e->_source->position) );
Vector2 target= Panel_pixelFromPosition(self, &(e->_target->position) );
DrawLineV(source, target, BLUE);
Vector2 ortho= (Vector2){ target.x-source.x, target.y-source.y }; // Vector from Source to Target
float ratio= 10.f / Vector2Length( ortho );
ortho= (Vector2){ -ortho.y*ratio, ortho.x*ratio };// 10 ortho-normal vector from v
Vector2 source1= (Vector2){source.x-ortho.x, source.y-ortho.y};
Vector2 source2= (Vector2){source.x+ortho.x, source.y+ortho.y};
DrawTriangle(source1, source2, target, BLUE);
}
Vector2 Panel_pixelFromPosition(Panel * self, Vector2 * p)
......
......@@ -3,6 +3,15 @@
#include "networld.h"
// Tools
void printVector2( Vector2 v );
//-----------------------------------//
//-- Cotrol Panel --//
//-----------------------------------//
struct Str_Panel {
Vector2 camera, screenCenter;
float scale; // meter per pixel
......
......@@ -37,7 +37,7 @@ int main(int nbArg, char ** arg)
NetWorld_connect(world, 0, 1);
NetWorld_connect(world, 1, 2);
NetWorld_connect(world, 2, 0);
NetWorld_biconnect(world, 2, 0);
Panel * panel= Panel_new();
Panel_initialize(panel, world);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment